Remove excerpts from homepage - php

My page is http://prowrestlingnews.co. I am looking to remove the excerpts from the homepage, as this is a news headline website. I prefer for the main content (middle section) to display headlines like it does on the right sidebar with the "Latest Wrestling News" widget.
I have been playing around with the index and functions file, but can't seem to remove the excerpts. Any help would be greatly appreciated!
Here's the index.php file:
<?php
/**
* The main template file.
*
* Used to display the homepage when home.php doesn't exist.
*/
?>
<?php $mts_options = get_option(MTS_THEME_NAME); ?>
<?php get_header(); ?>
<div id="page">
<div class="article">
<div id="content_box">
<?php if ( !is_paged() ) { ?>
<?php if ( is_home() && $mts_options['mts_featured_slider'] == '1' ) { ?>
<div class="primary-slider-container clearfix loading">
<div id="slider" class="primary-slider">
<?php if ( empty( $mts_options['mts_custom_slider'] ) ) { ?>
<?php
// prevent implode error
if ( empty( $mts_options['mts_featured_slider_cat'] ) || !is_array( $mts_options['mts_featured_slider_cat'] ) ) {
$mts_options['mts_featured_slider_cat'] = array('0');
}
$slider_cat = implode( ",", $mts_options['mts_featured_slider_cat'] );
$slider_query = new WP_Query('cat='.$slider_cat.'&posts_per_page='.$mts_options['mts_featured_slider_num']);
while ( $slider_query->have_posts() ) : $slider_query->the_post();
?>
<div>
<a href="<?php echo esc_url( get_the_permalink() ); ?>">
<?php the_post_thumbnail('schema-slider',array('title' => '')); ?>
<div class="slide-caption">
<h2 class="slide-title"><?php the_title(); ?></h2>
</div>
</a>
</div>
<?php endwhile; wp_reset_postdata(); ?>
<?php } else { ?>
<?php foreach( $mts_options['mts_custom_slider'] as $slide ) : ?>
<div>
<a href="<?php echo esc_url( $slide['mts_custom_slider_link'] ); ?>">
<?php echo wp_get_attachment_image( $slide['mts_custom_slider_image'], 'schema-slider', false, array('title' => '') ); ?>
<div class="slide-caption">
<h2 class="slide-title"><?php echo esc_html( $slide['mts_custom_slider_title'] ); ?></h2>
</div>
</a>
</div>
<?php endforeach; ?>
<?php } ?>
</div><!-- .primary-slider -->
</div><!-- .primary-slider-container -->
<?php } ?>
<?php
$featured_categories = array();
if ( !empty( $mts_options['mts_featured_categories'] ) ) {
foreach ( $mts_options['mts_featured_categories'] as $section ) {
$category_id = $section['mts_featured_category'];
$featured_categories[] = $category_id;
$posts_num = $section['mts_featured_category_postsnum'];
if ( 'latest' == $category_id ) { ?>
<?php $j = 0; if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<article class="latestPost excerpt <?php echo (++$j % 3 == 0) ? 'last' : ''; ?>">
<?php mts_archive_post(); ?>
</article>
<?php endwhile; endif; ?>
<?php if ( $j !== 0 ) { // No pagination if there is no posts ?>
<?php mts_pagination(); ?>
<?php } ?>
<?php } else { // if $category_id != 'latest': ?>
<h3 class="featured-category-title"><?php echo esc_html( get_cat_name( $category_id ) ); ?></h3>
<?php
$j = 0;
$cat_query = new WP_Query('cat='.$category_id.'&posts_per_page='.$posts_num);
if ( $cat_query->have_posts() ) : while ( $cat_query->have_posts() ) : $cat_query->the_post(); ?>
<article class="latestPost excerpt <?php echo (++$j % 3 == 0) ? 'last' : ''; ?>">
<?php mts_archive_post(); ?>
</article>
<?php
endwhile; endif; wp_reset_postdata();
}
}
}
?>
<?php } else { //Paged ?>
<?php $j = 0; if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<article class="latestPost excerpt <?php echo (++$j % 3 == 0) ? 'last' : ''; ?>">
<?php mts_archive_post(); ?>
</article>
<?php endwhile; endif; ?>
<?php if ( $j !== 0 ) { // No pagination if there is no posts ?>
<?php mts_pagination(); ?>
<?php } ?>
<?php } ?>
</div>
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
Functions.php file viewed at https://gist.github.com/pwz2k/16a8aa858ee3d739276c67d56fbccca9

Related

only displays certain category

I'm building my own website just for fun and for learning.
I want to display only the post with a certain category # my homepage.
I've tried a number of things but they don't seem to work
at my home.php
this is what te code looks like.
get_header(); ?>
<?php $blog_layout = get_theme_mod('blog_layout', 'small-images'); ?>
<?php if ( ($blog_layout == 'masonry') || ($blog_layout == 'fullwidth') ) {
$layout = 'fullwidth';
} else {
$layout = '';
} ?>
<?php if ( $blog_layout == 'masonry' ) {
$masonry = 'home-masonry';
} else {
$masonry = '';
} ?>
<div id="primary" class="content-area <?php echo $layout; ?>">
<main id="main" class="site-main" role="main">
<span class="diensten">ONZE DIENSTEN..</span>
<div class="diensten-content">
<?php if ( have_posts() ) : ?>
<?php /* Start the Loop */ ?>
<div class="home-wrapper <?php echo $masonry; ?>">
<?php while ( have_posts() ) : the_post(); ?>
<?php
if ( $blog_layout == 'large-images' || $blog_layout == 'masonry' ) {
get_template_part( 'content', 'large' );
} else {
get_template_part( 'content', get_post_format() );
}
?>
<?php endwhile; ?>
</div>
<?php moesia_paging_nav(); ?>
<?php else : ?>
<?php get_template_part( 'content', 'none' ); ?>
<?php endif; ?>
</div><!--diensten-content-->
<
</main><!-- #main -->
</div><!-- #primary -->
And at content.php
<article id="post-<?php the_ID(); ?>" <?php post_class(''); ?>>
<?php if ( has_post_thumbnail() ) : ?>
<div class="entry-thumb">
<a href="<?php the_permalink(); ?>" class="H1-posts" title="<?php the_title(); ?>" >
<?php the_post_thumbnail('moesia-thumb'); ?>
</a>
</div>
<?php endif; ?>
<?php if (has_post_thumbnail()) : ?>
<?php $has_thumb = ""; ?>
<?php else : ?>
<?php $has_thumb = ""; ?>
<?php endif; ?>
<div class="post-content <?php echo $has_thumb; ?>">
<header class="entry-header">
<?php the_title( sprintf( '<h1 class="entry-title">', esc_url( get_permalink() ) ), '</h1>' ); ?>
<?php if ( 'post' == get_post_type() ) : ?>
<?php endif; ?>
</header><!-- .entry-header -->
<div class="entry-summary">
<?php if ( (get_theme_mod('full_content') == 1) && is_home() ) : ?>
<?php the_content(); ?>
<?php else : ?>
<?php the_excerpt(); ?>
<?php endif; ?>
</div><!-- .entry-content -->
I've tried this..`
<?php
//refine your query to the category you desire either a slug(example below) or category id
$args = array(
'category_name' => 'my_category_slug',
);
//create the query using the arguments
$query = new WP_Query($args);
?>
//create the loop to show the posts
<?php if($query->have_posts()): ?>
<?php while($query->have_posts()): $query->the_post(); ?>
<h1><?php the_title(); ?></h1>
<div><?php the_content(); ?></div>
<?php endwhile; ?>
<?php endif; ?>
did not work. How do I fix this?`If It displays only the posts with a certain class if also good.
Thanks..

ACF if have_rows( ) not returning anything

I'm trying to use a repeater field and can't seem to get it to work. I think it's an issue with my if statement because if I remove the while loop and try echo out anything from <?php if( have_rows($aboutInfo['cards']): ?> I get nothing. I've tried without the ID, and a hardcoded ID as the 2nd param. Also, just to test I did <?php if( !have_rows($aboutInfo['cards']): ?> and was able to get something to echo out.
The print_r above the if statement displays the array.
<?
/*
Template Name: 01-Homepage
*/
get_header(); ?>
<? $aboutInfo = get_field( 'about' ) ?>
<?$postid = get_the_ID(); ?>
<div class="row">
<div class="columns small-12 medium-7">
<h2>
<?= $aboutInfo['title'] ?>
</h2>
<p class="lead"> <?= $aboutInfo['content'] ?></p>
<pre><?php print_r($aboutInfo['cards']) ?></pre>
<?php if( have_rows($aboutInfo['cards'], $postid) ): ?>
<?php while(have_rows($aboutInfo['cards'])) : the_row(); ?>
<?php $image = get_sub_field('image') ?>
<p><?= $image['url'] ?></p>
<?php endwhile; ?>
<?php endif; ?>
</div>
</div>
<?php get_footer(); ?>
Here is what my ACF looks like
I think you are doing it wrong. There are so many bugs in your code. check
https://www.advancedcustomfields.com/resources/group/ and have_rows() the first param need to be selector. check below code.
<?php
/* Template Name: 01-Homepage */
get_header();
$aboutInfo = get_field( 'about' );
$postid = get_the_ID();
if( have_rows('about') ):
$title = get_sub_field('title');
$content = get_sub_field('content');
?>
<div class="row">
<div class="columns small-12 medium-7">
<?php while( have_rows( 'about' ) ): the_row(); ?>
<h2><?php echo $title; ?></h2>
<p class="lead"><?php echo $content; ?></p>
<?php if( have_rows( 'cards' ) ): while( have_rows( 'cards' ) ) : the_row(); ?>
<?php $image = get_sub_field( 'image' ); ?>
<img src="<?php echo $image['url']; ?>" />
<?php endwhile; endif;
endwhile; ?>
</div>
</div>
<?php endif;
get_footer(); ?>
The issues was that I created a group called "about" and the "cards" were nested in that group and to access that field I needed to use "about_cards".
<?
/*
Template Name: 01-Homepage
*/
get_header(); ?>
​
<?php while ( have_posts() ) : the_post();
​
// group field
$about = get_field( 'about' );
if ( !empty( $about ) ) { ?>
​
<div class="row">
<div class="columns small-12 medium-7">
​
<?php if ( !empty( $about['title'] ) ) { ?>
<h2><?php echo esc_html( $about['title'] ); ?></h2>
<?php }
if ( !empty( $about['content'] ) ) { ?>
<p class="lead"><?php echo wp_kses_post( $about['content'] ); ?></p>
<?php }
​
if( have_rows( 'about_cards' ) ) : // repeater
​
while ( have_rows( 'about_cards' ) ) : the_row();
​
$about_card_image = get_sub_field('image');
$about_card_title = get_sub_field('title');
$about_card_content = get_sub_field('content');
​
if ( !empty( $about_card_image ) ) {
echo wp_get_attachment_image( $about_card_image, 'medium' );
}
​
if ( !empty( $about_card_title ) ) {
echo '<h3>' . esc_html( $about_card_title ) . '</h3>';
}
​
if ( !empty( $about_card_content ) ) {
echo '<p>' . esc_html( $about_card_content ) . '</p>';
} ?>
​
<?php endwhile;
endif; ?>
</div>
</div>
​
<?php } // about field not empty ?>
​
<?php endwhile; // End of the loop. ?>
​
<?php get_footer(); ?>

add badge to thumbnail image

What I want to do on the front page where I have recent posts, is to add a small upper corner badge or ribbon that says "NEW" to the thumbnails of posts that were published on today's date. Below is my index.php which controls the front page layout:
<?php
/**
* The main template file.
*
* Used to display the homepage when home.php doesn't exist.
*/
?>
<?php
// Get options
$mts_options = get_option(MTS_THEME_NAME);
// Featured Section 1 settings ( slider is here) --------------------------------
$slider_enabled = ( $mts_options['mts_featured_slider'] === '1' ) ? true : false;
if ( empty($mts_options['mts_featured_slider_cat']) || !is_array($mts_options['mts_featured_slider_cat']) ) {
$mts_options['mts_featured_slider_cat'] = array('0');
}
$slider_cat = implode(",", $mts_options['mts_featured_slider_cat']);
// Featured Section settings --------------------------------------------------
$f2_title = $mts_options['mts_featured_section_2_title'];
if ( empty($mts_options['mts_featured_section_2_cat']) || !is_array($mts_options['mts_featured_section_2_cat']) ) {
$mts_options['mts_featured_section_2_cat'] = array('0');
}
$f2_cat= implode(",", $mts_options['mts_featured_section_2_cat']);
// Featured Section 3 settings --------------------------------------------------
get_header(); ?>
<div id="page">
<div class="article">
<?php if ( $slider_enabled && is_home() && !is_paged() ) { ?>
<section id="featured-section-1" class="featured-section featured-section-1-1 clearfix">
<div class="slider-container">
<div class="primary-slider-container clearfix loading">
<div id="slider" class="primary-slider">
<?php
$slider_full = 'best-featuredfull';
if ( empty( $mts_options['mts_custom_slider'] ) ) {
$my_query = new WP_Query('cat='.$slider_cat.'&posts_per_page='.$mts_options['mts_featured_slider_num']);
while ( $my_query->have_posts() ) : $my_query->the_post();
?>
<div>
<a href="<?php the_permalink(); ?>">
<?php the_post_thumbnail($slider_full,array('title' => '')); ?>
<div class="slider-caption">
<?php if(isset($mts_options['mts_home_headline_meta_info']['enabled']) && $mts_options['mts_home_headline_meta_info']['enabled']){ ?>
<div class="sliderdate">
<?php if(isset($mts_options['mts_home_headline_meta_info']['enabled']['date']) == '1') { ?>
<span class="thetime updated"><?php the_time( get_option( 'date_format' ) ); ?></span>
<?php } ?>
</div>
<?php } ?>
<h2 class="slide-title"><?php the_title(); ?></h2>
</div>
<div class="post-day"><?php if (function_exists('wp_review_show_total')) wp_review_show_total(true, 'review-total-only'); ?></div>
</a>
</div>
<?php endwhile; wp_reset_postdata();
} else { ?>
<?php foreach( $mts_options['mts_custom_slider'] as $slide ) : ?>
<div>
<a href="<?php echo esc_url( $slide['mts_custom_slider_link'] ); ?>">
<?php echo wp_get_attachment_image( $slide['mts_custom_slider_image'], $slider_full, false, array('title' => '') ); ?>
<div class="slider-caption">
<div class="sliderdate"><?php echo esc_html( $slide['mts_custom_slider_title'] ); ?></div>
<h2 class="slide-title"><?php echo esc_html( $slide['mts_custom_slider_text'] ); ?></h2>
</div>
</a>
</div>
<?php endforeach; ?>
<?php } ?>
</div>
</div>
</div><!-- slider-container -->
</section>
<?php } ?>
<?php if( $mts_options['mts_featured_section_2'] === '1' && is_home() && !is_paged() ) {// featured section 2 ?>
<section id="featured-section-3" class="featured-section clearfix">
<?php if (!empty($f2_title)) { ?><h4 class="featured-section-title"><?php echo $f2_title;?></h4><?php } ?>
<?php
$f2_query = new WP_Query('cat='.$f2_cat.'&posts_per_page=4');
$f2_count = 1; if ($f2_query->have_posts()) : while ($f2_query->have_posts()) : $f2_query->the_post();
$f2_loop_params = best_mixed_layout_params( 1, 2, $f2_count );// see functions.php
$f2_clear_class = $f2_loop_params['clear_class'];
$f2_type_class = $f2_loop_params['box_class'];
$f2_loop_thumb = $f2_loop_params['thumb'];
$f2_show_excerpt = $f2_loop_params['show_excerpt'];
$f2_show_author = $f2_loop_params['show_author'];
$begin_f2_extra_wrappers = $f2_loop_params['open_wrappers'];
$end_f2_extra_wrappers = $f2_loop_params['close_wrappers'];
?>
<article class="post-box latestPost mixed <?php echo $f2_type_class;?> <?php echo $f2_clear_class;?>">
<?php echo $begin_f2_extra_wrappers; ?>
<div class="post-img">
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" rel="nofollow">
<?php the_post_thumbnail($f2_loop_thumb,array('title' => '')); ?>
</a>
</div>
<div class="post-data">
<div class="post-data-container">
<header>
<h2 class="title post-title"><?php the_title(); ?></h2>
<?php mts_the_postinfo(); ?>
</header>
<?php if ($f2_show_excerpt) : ?>
<div class="post-excerpt">
<?php echo mts_excerpt(40); ?>
</div>
<?php endif; ?>
</div>
</div>
<?php echo $end_f2_extra_wrappers; ?>
</article><!--.post-box-->
<?php $f2_count++; endwhile;
endif; wp_reset_postdata();
?>
</section><!--#featured-section-3-->
<?php } ?>
<div id="content_box">
<?php $latest_posts_used = false;
if ( !empty( $mts_options['mts_featured_categories'] ) ) {
foreach ( $mts_options['mts_featured_categories'] as $section ) {
$category_id = $section['mts_featured_category'];
$featured_category_layout = $section['mts_featured_category_layout'];
$posts_num = $section['mts_featured_category_postsnum'];
if ( $category_id === 'latest' && ! $latest_posts_used ) {
$latest_posts_used = true;
$fc_section_class = ( in_array( $featured_category_layout, array( 'vertical', 'mixed' ) ) ) ? '' : ' '.$featured_category_layout;
?>
<section id="latest-posts" class="clearfix<?php echo $fc_section_class ?><?php //echo $fc_section_no_gap ?>">
<h4 class="featured-section-title"><?php _e( "Latest", "best" ); ?></h4>
<?php $j = 1; if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php best_the_homepage_article( $featured_category_layout, $j, true );?>
<?php $j++; endwhile; endif; ?>
<!--Start Pagination-->
<?php if (isset($mts_options['mts_pagenavigation_type']) && $mts_options['mts_pagenavigation_type'] == '1' ) { ?>
<?php $additional_loop = 0; mts_pagination($additional_loop['max_num_pages']); ?>
<?php } else { ?>
<div class="pagination pagination-previous-next">
<ul>
<li class="nav-previous"><?php next_posts_link( '<i class="fa fa-chevron-left"></i> '. __( 'Previous', 'best' ) ); ?></li>
<li class="nav-next"><?php previous_posts_link( __( 'Next', 'best' ).' <i class="fa fa-chevron-right"></i>' ); ?></li>
</ul>
</div>
<?php } ?>
<!--End Pagination-->
</section><!--#latest-posts-->
<?php } elseif ( $category_id !== 'latest' && !is_paged() ) {
$fc_section_class = ( in_array( $featured_category_layout, array( 'vertical', 'mixed' ) ) ) ? '' : ' '.$featured_category_layout;
?>
<section class="featured-section clearfix<?php echo $fc_section_class ?>">
<h4 class="featured-section-title"><?php echo get_cat_name($category_id); ?></h4>
<?php $cat_query = new WP_Query('cat='.$category_id.'&posts_per_page='.$posts_num); ?>
<?php $j = 1; if ($cat_query->have_posts()) : while ($cat_query->have_posts()) : $cat_query->the_post(); ?>
<?php best_the_homepage_article( $featured_category_layout, $j );?>
<?php $j++; endwhile; endif; wp_reset_postdata();?>
</section>
<?php } ?>
<?php } ?>
<?php } ?>
</div>
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
What I have is this: to check the date and display the badge (not including css) but not sure where to input it exactly:
<?php
$days_old = (current_time(timestamp) - get_the_time('U') - (get_settings('gmt_offset') *3600 ) ) / (60*60*24);
if ($days_old <=1) {
echo <div class="post-badge">NEW</div>;
}
?>
I want to insert it into The Latest Post Section. Any help would be greatly appreciated:)

PHP Add every 2 items inside DIV in WordPress loop

I need PHP code to add every 2 items inside DIV in WordPress loop.
For example, I need like this:
<div class="wrap">
post
post
</div>
<div class="wrap">
post
post
</div>
<div class="wrap">
post
post
</div>
This is my wordpress loop, but not working, I need every 2 posts inside DIV:
<?php if ( have_posts() ) : // If have post start. ?>
<?php $i = 0; ?>
<?php while ( have_posts() ) : the_post(); // Start Loop: ?>
<?php if ( $i % 2 == 0) : ?>
<div class="wrap">
<?php endif; ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php the_content(); ?>
</article>
<?php if ( $i % 2 == 0 ) : ?>
</div>
<?php endif; ?>
<?php $i++; endwhile; // End Loop. ?>
<?php endif; // If have post end. ?>
Thanks.
The problem is that you print both <div> and </div> on even values of $i. That's why they always wrap only one and the second post stands aside.
You have to echo the <div> on even numbers and </div> on odd:
<?php if ( have_posts() ) : // If have post start. ?>
<?php $i = 0; ?>
<?php while ( have_posts() ) : the_post(); // Start Loop: ?>
<?php if ( $i % 2 == 0) : ?>
<div class="wrap">
<?php endif; ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php the_content(); ?>
</article>
<!-- changed == 0 to != 0 -->
<?php if ( $i % 2 != 0 ) : ?>
</div>
<?php endif; ?>
<?php $i++; endwhile; // End Loop. ?>
<!-- added closing </div> for odd number of posts -->
<?php if ( $i % 2 != 0 ) : ?>
</div>
<?php endif; ?>
<?php endif; // If have post end. ?>
I added a second </div> after the loop, because without it you wouldn't get the closing tag at all if you have an odd number of posts.
I think this should do the job:
<div class="wrap">
<?php
$query = new WP_Query();
if ( $query->have_posts() ):
$i=0;
while ( $query->have_posts() ) :
$query->the_post();
if($i%2==0 && $i<$query->post_count-1 && $i>0):
echo '</div><div class="wrap">'
endif;
?>
<!--html here-->
<?php
$i++;
endwhile;
endif;
?>
</div>
You should do something like this:
<?php
if ( have_posts() ) {
$i=0;
while ( have_posts() ) {
if($i%2==0):?>
<div class="wrap">
<?php
else : ?>
</div>
<?php
endif;
$i++;
}
}
?>
Ok, based on the answer by Aviram here I created this:
$i = 1;
$out = '';
$endingNeeded = false;
if ( have_posts() ) {
while ( have_posts() ) {
if ( $i % 2 == 1) {
$out .= '<div class="wrap">';
$endingNeeded = true;
}
the_post(); // Start Loop:
$out .= '<article id="post-'. get_the_ID().'" class="'.implode(get_post_class(), ', ').'">
'.get_the_content().'
</article>';
if ( $i % 2 == 0 ) {
$out .= '</div>';
$endingNeeded = false;
}
$i++;
}
}
if($endingNeeded) {
$out .= '</div>';
}
echo $out;
Should be working fine.
Correct loop should look like this:
<?php if(have_posts()) : ?>
<?php $no_of_posts = wp_count_posts()->publish; ?>
<div class="wrap">
<?php $i=1; while(have_posts()) : the_post(); ?>
<div class="post">
post text
</div>
<?php if($i%2==0 && $i!=$no_of_posts) : ?>
</div>
<div class="wrap">
<?php endif; ?>
<?php $i++; endwhile; ?>
</div>
<?php endif; ?>
You meaning this like?
<?php
if ( have_posts() ) {
while ( have_posts() ) {
for ($i=0; $i<2; $i++) {
// what do you like to do
?>
<!-- HTML CODE -->
<?php
}
}
}else{
// ...
}
?>
Why do you not add a simple for loop in the WordPress loop?

Display latest posts from a specific tag in Wordpress

I am trying to alter my Wordpress theme to display the latest posts from a specific tag. It currently lists the latest posts overall.
Here is part of the code that it uses:
<?php
if ( is_home() ) {
$args=array(
'showposts'=> (int) get_option('aggregate_homepage_posts'),
'paged'=>$paged,
'category__not_in' => (array) get_option('aggregate_exlcats_recent')
);
if (get_option('aggregate_duplicate') == 'false') {
global $ids;
$args['post__not_in'] = $ids;
}
query_posts($args);
global $paged;
}
$i = 0;
?>
<?php
if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php
$i++;
$et_is_latest_post = ( $paged == 0 && ( is_home() && $i <= 2 ) ) || !is_home();
?>
<div class="post entry clearfix<?php if ( $et_is_latest_post ) echo ' latest'; ?>">
<?php
$thumb = '';
$width = $et_is_latest_post ? 170 : 67;
$height = $et_is_latest_post ? 110 : 67;
$classtext = 'post-thumb';
$titletext = get_the_title();
$thumbnail = get_thumbnail($width,$height,$classtext,$titletext,$titletext,false,'Entry');
$thumb = $thumbnail["thumb"];
?>
<?php if($thumb <> '' && get_option('aggregate_thumbnails_index') == 'on') { ?>
<div class="thumb thumbcont">
<a href="<?php the_permalink(); ?>">
<?php print_thumbnail($thumb, $thumbnail["use_timthumb"], $titletext, $width, $height, $classtext); ?>
<span class="overlay"></span>
</a>
<a class="thumb<?php $category = get_the_category(); echo $category[0]->category_nicename; ?>" href="<?php bloginfo('url'); ?>/<?php echo $category[0]->category_nicename; ?>"><?php echo $category[0]->cat_name; ?></a>
</div> <!-- end .post-thumbnail -->
<?php } ?>
<h3 class="title"><?php the_title(); ?></h3>
<?php get_template_part('includes/postinfo'); ?>
<p class="postsummery">
<?php
$excerpt = get_the_excerpt();
echo string_limit_words($excerpt,20);
?>
</p>
<span><?php esc_html_e('Read More','Aggregate'); ?></span>
</div> <!-- end .post-->
<?php endwhile; ?>
<?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); }
else { ?>
<?php get_template_part('includes/navigation','entry'); ?>
<?php } ?>
<?php else : ?>
<?php get_template_part('includes/no-results','entry'); ?>
<?php endif; wp_reset_query(); ?>
While doing some research, I found some details of how to do this:
http://codex.wordpress.org/Template_Tags/get_posts
However, my very limited knowledge of PHP coding and lack of understanding how my current code works with the examples provided, I cannot find a way to do it. Can you guide me?
You simple add 'tag'=>the tag u wanted listed, after array( at line3
why well cause that's the array containing the arguments that then will be passed to the get posts function that makes a call to the database, the arguments that you got to choose from can be find here http://codex.wordpress.org/Class_Reference/WP_Query#Tag_Parameters
And the full code would look like so
<?php
if ( is_home() ) {
$args=array(
'showposts'=> (int) get_option('aggregate_homepage_posts'),
'paged'=>$paged,
'tag'=>"the tag u want shown",
'category__not_in' => (array) get_option('aggregate_exlcats_recent')
);
if (get_option('aggregate_duplicate') == 'false') {
global $ids;
$args['post__not_in'] = $ids;
}
query_posts($args);
global $paged;
}
$i = 0;
?>
<?php
if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php
$i++;
$et_is_latest_post = ( $paged == 0 && ( is_home() && $i <= 2 ) ) || !is_home();
?>
<div class="post entry clearfix<?php if ( $et_is_latest_post ) echo ' latest'; ?>">
<?php
$thumb = '';
$width = $et_is_latest_post ? 170 : 67;
$height = $et_is_latest_post ? 110 : 67;
$classtext = 'post-thumb';
$titletext = get_the_title();
$thumbnail = get_thumbnail($width,$height,$classtext,$titletext,$titletext,false,'Entry');
$thumb = $thumbnail["thumb"];
?>
<?php if($thumb <> '' && get_option('aggregate_thumbnails_index') == 'on') { ?>
<div class="thumb thumbcont">
<a href="<?php the_permalink(); ?>">
<?php print_thumbnail($thumb, $thumbnail["use_timthumb"], $titletext, $width, $height, $classtext); ?>
<span class="overlay"></span>
</a>
<a class="thumb<?php $category = get_the_category(); echo $category[0]->category_nicename; ?>" href="<?php bloginfo('url'); ?>/<?php echo $category[0]->category_nicename; ?>"><?php echo $category[0]->cat_name; ?></a>
</div> <!-- end .post-thumbnail -->
<?php } ?>
<h3 class="title"><?php the_title(); ?></h3>
<?php get_template_part('includes/postinfo'); ?>
<p class="postsummery">
<?php
$excerpt = get_the_excerpt();
echo string_limit_words($excerpt,20);
?>
</p>
<span><?php esc_html_e('Read More','Aggregate'); ?></span>
</div> <!-- end .post-->
<?php endwhile; ?>
<?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); }
else { ?>
<?php get_template_part('includes/navigation','entry'); ?>
<?php } ?>
<?php else : ?>
<?php get_template_part('includes/no-results','entry'); ?>
<?php endif; wp_reset_query(); ?>

Categories