Wordpress post repeat twice at the last page - wordpress

I try to display my post using two column, to make sure the fit each other, I tried to create two vertical column, and display the post odd and even seperately. Odd on left side, and even on the right side. And im suing wp_pagenavi() to get navigation working, other page work fine, display the post as I intend it to be, but on the last page, one post will repeat twice.
Here my code for the looping part
<?php if ( have_posts() ) : ?>
<?php /* Start the Loop */ ?>
<div id="holder" class="left">
<?php while ( have_posts() ) : ?>
<?php
$postcount++;
if( ($postcount % 2) == 0 ) : // skip 'even' posts
$wp_query->next_post();
else :
?>
<?php the_post(); ?>
<div class="fpost">
<div class="fposttitle">
<h1 class="left"><?php the_title(); ?></h1>
<?php if ( comments_open() || ( '0' != get_comments_number() && ! comments_open() ) ) : ?>
<div class="combox right">
<?php $x = get_comments_number(); if ($x < 10) : ?>
<?php comments_popup_link( __( '00', 'toolbox' ), __( '01', 'toolbox' ), __( '0%', 'toolbox' ) ); ?>
<?php else : ?>
<?php comments_popup_link( __( '00', 'toolbox' ), __( '01', 'toolbox' ), __( '%', 'toolbox' ) ); ?>
<?php endif; ?>
</div>
<?php endif; ?>
<div class="clear"></div>
</div>
<div class="fcontent">
<?php $thumbnail = get_post_meta(get_the_ID(), 'thumbnail', true);
if ($thumbnail) : ?>
<img src="<?php echo $thumbnail; ?>" alt="<?php the_permalink(); ?>" />
<?php else : ?>
<p><?php the_excerpt(); ?></p>
<?php endif; ?>
</div>
<div class="finfo">
<p class="left date"><?php the_time('F j, Y') ?></p>
<p class="left cat"><?php the_category(', ') ?></p>
<p class="right"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'toolbox' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark" >Read More</a></p>
<div class="clear"></div>
</div>
</div>
<?php endif; ?>
<?php endwhile; ?>
</div><!-- #content -->
<div id="holder2" class="left">
<?php while ( have_posts() ) : ?>
<?php
$postcount++;
if( ($postcount % 2) != 0 ) : // skip 'odd' posts
$wp_query->next_post();
else :
?>
<?php the_post(); ?>
<div class="fpost">
<div class="fposttitle">
<h1 class="left"><?php the_title(); ?></h1>
<?php if ( comments_open() || ( '0' != get_comments_number() && ! comments_open() ) ) : ?>
<div class="combox right">
<?php $x = get_comments_number(); if ($x < 10) : ?>
<?php comments_popup_link( __( '00', 'toolbox' ), __( '01', 'toolbox' ), __( '0%', 'toolbox' ) ); ?>
<?php else : ?>
<?php comments_popup_link( __( '00', 'toolbox' ), __( '01', 'toolbox' ), __( '%', 'toolbox' ) ); ?>
<?php endif; ?>
</div>
<?php endif; ?>
<div class="clear"></div>
</div>
<div class="fcontent">
<?php $thumbnail = get_post_meta(get_the_ID(), 'thumbnail', true);
if ($thumbnail) : ?>
<img src="<?php echo $thumbnail; ?>" alt="<?php the_permalink(); ?>" />
<?php else : ?>
<p><?php the_excerpt(); ?></p>
<?php endif; ?>
</div>
<div class="finfo">
<p class="left date"><?php the_time('F j, Y') ?></p>
<p class="left cat"><?php the_category(', ') ?></p>
<p class="right"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'toolbox' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark" >Read More</a></p>
<div class="clear"></div>
</div>
</div>
<?php endif; ?>
<?php endwhile; ?>
</div><!-- #content -->
<?php else : ?>
no post
<?php endif; ?>
<div class="clear"></div>
<div id="nav"> <?php wp_pagenavi() ?> </div>
</div><!-- #primary -->
I thinking maybe because last page, there is not enough number post, but can't figure out why the post repeat.
update: I just tried to add one new post, and everything work fine. but when I add another post, it the last page repeat same post again.

Probably should have included this as an answer instead of a comment, in the case where you have an odd number of posts, you don't reset your $postcount variable to 0, so your 2nd loop doesn't necessarily start on the same condition that the first loop did. So on your last page you're able to notice this happening, but chances are on the other pages you're skipping certain posts altogether:
<?php if ( have_posts() ) : ?>
<?php /* Start the Loop */ ?>
<div id="holder" class="left">
<?php $postcount = 0; ?>
<?php while ( have_posts() ) : ?>
<?php
$postcount++;
if( ($postcount % 2) == 0 ) : // skip 'even' posts
$wp_query->next_post();
else :
?>
<?php the_post(); ?>
<?php endif; ?>
<?php endwhile; ?>
...
</div><!-- #content -->
<div id="holder2" class="left">
<?php $postcount = 0; ?>
<?php rewind_posts();//rewind the post counter so you can do another loop ?>
<?php while ( have_posts() ) : ?>
<?php
$postcount++;
if( ($postcount % 2) != 0 ) : // skip 'odd' posts
$wp_query->next_post();
else :
?>
<?php the_post(); ?>
...
<?php endif; ?>
<?php endwhile; ?>
</div><!-- #content -->

Related

Regular posts first (descending order), then custom post type (alphabetical) in WP search

I've been cobbling together bits and pieces of various examples together but can't seem to wrap my head around this.
I have regular blog posts (News) that I would like displayed with the most recent on top followed by a custom post type (Businesses) that I would like grouped below the News. I am using Sage and this is my first theme.
Here is my beginner code so far:
<?php get_template_part('templates/page', 'header'); ?>
<?php if (!have_posts()) : ?>
<div class="alert alert-warning">
<?php _e('Sorry, no results were found.', 'sage'); ?>
</div>
<?php get_search_form(); ?>
<?php endif; ?>
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php $post_type = get_post_type_object( get_post_type() ); ?>
<?php $type = get_post_type(); ?>
<?php if ($type == 'post') { ?>
<h2>News Results</h2>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<div>
<a href="<?php the_permalink(); ?>">
<?php $cats=get_the_category(); ?>
<?php echo $cats[0]->cat_name; ?>
</a>
</div>
<div>
<h3><?php the_title(); ?></h3>
<div class="result-excerpt">
<?php if ( has_excerpt( $post->ID ) ) {
echo the_excerpt();
} else {
echo get_excerpt();
} ?>
</div>
</div>
</article>
<?php } elseif ($type == 'business') { ?>
<h2>Business Results</h2>
<article <?php post_class(); ?>>
<header>
<h2 class="entry-title"><?php the_title(); ?></h2>
<?php if (get_post_type() === 'post') { get_template_part('templates/entry-meta'); } ?>
</header>
<div class="entry-summary">
<?php the_excerpt(); ?>
</div>
<a href="<?php the_permalink(); ?>">
<?php $cats=get_the_category(); ?>
<?php echo $cats[0]->cat_name; ?> -
<?php the_title(); ?>
</a>
<h3><?php echo the_sub_field('title'); ?></h3>
<?php if( get_sub_field('content') ): ?>
<div class="result-excerpt">
<?php echo custom_field_excerpt(); ?>
</div>
<?php endif; ?>
</article>
<?php } ?>
<?php endwhile; ?>
<?php endif; ?>
I think the problem is that you're looping over every post, in order, and deciding what to do with it. This will result in the output, whatever it is, in the same order as the input.
I don't speak very fluent PHP, but I think what's happening is that the algorithm reads like this:
-for each post:
- if it's a 'post', display it like «this»
- otherwise, if it's a 'business', display it instead like «this»
I think you want to have two loops, like this:
-for each post:
- if it's a 'post', display it like «this»
-for each post:
- if it's a 'business', display it like «this»
Unfortunately, I don't see an obvious reference to store in an array and loop over. I really don't know how sage works, so I'll have to leave the implementation to you. My best guess - and I sincerely doubt this will work - is as follows:
<?php get_template_part('templates/page', 'header'); ?>
<?php if (!have_posts()) : ?>
<div class="alert alert-warning">
<?php _e('Sorry, no results were found.', 'sage'); ?>
</div>
<?php get_search_form(); ?>
<?php endif; ?>
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php $post_type = get_post_type_object( get_post_type() ); ?>
<?php $type = get_post_type(); ?>
<?php if ($type == 'post') { ?>
<h2>News Results</h2>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<div>
<a href="<?php the_permalink(); ?>">
<?php $cats=get_the_category(); ?>
<?php echo $cats[0]->cat_name; ?>
</a>
</div>
<div>
<h3><?php the_title(); ?></h3>
<div class="result-excerpt">
<?php if ( has_excerpt( $post->ID ) ) {
echo the_excerpt();
} else {
echo get_excerpt();
} ?>
</div>
</div>
</article>
<?php endwhile; ?>
<?php endif; ?>
<?php if (!have_posts()) : ?>
<div class="alert alert-warning">
<?php _e('Sorry, no results were found.', 'sage'); ?>
</div>
<?php get_search_form(); ?>
<?php endif; ?>
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php $post_type = get_post_type_object( get_post_type() ); ?>
<?php $type = get_post_type(); ?>
<?php if ($type == 'business') { ?>
<h2>Business Results</h2>
<article <?php post_class(); ?>>
<header>
<h2 class="entry-title"><?php the_title(); ?></h2>
<?php if (get_post_type() === 'post') { get_template_part('templates/entry-meta'); } ?>
</header>
<div class="entry-summary">
<?php the_excerpt(); ?>
</div>
<a href="<?php the_permalink(); ?>">
<?php $cats=get_the_category(); ?>
<?php echo $cats[0]->cat_name; ?> -
<?php the_title(); ?>
</a>
<h3><?php echo the_sub_field('title'); ?></h3>
<?php if( get_sub_field('content') ): ?>
<div class="result-excerpt">
<?php echo custom_field_excerpt(); ?>
</div>
<?php endif; ?>
</article>
<?php } ?>
<?php endwhile; ?>
<?php endif; ?>
Good luck!

How to get all the post titles on a specific page in WordPress

I want to display all the posts on a specific page called "Articles".
However, when I used the_title(); in a loop, it seems that the title of this page is displayed instead.
relative code in articles.php (linked to the Articles page created in dashboard)
<div class="container">
<?php if ( have_posts() ) : ?>
<div class="content">
<?php while ( have_posts() ) : the_post(); ?>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php get_template_part( 'content', get_post_format() ); ?>
</div>
<?php endwhile; ?>
</div>
<?php endif; ?>
</div>
content.php
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" class="post-header section medium-padding">
<div class="post-meta-top">
<?php the_time(get_option('date_format')); ?>
<?php
if ( comments_open() ) {
echo '<span class="sep">/</span> ';
if ( is_single() )
comments_popup_link( '0 comments', '1 comment', '% comments', 'post-comments' );
else
comments_number( '0 comments', '1 comment', '% comments' );
}
?>
</div>
<h2 class="post-title"><?php the_title(); ?></h2>
</a>
This part works well in index.php.
Step 1: Create a new template articles.php inside the folder of content.php and insert this code:
<?php
$articles = new WP_Query( array( 'posts_per_page' => -1 ) );
while ( $articles->have_posts() ) :
$articles->the_post();
?>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" class="post-header section medium-padding">
<div class="post-meta-top">
<?php the_time(get_option('date_format')); ?>
<?php
if ( comments_open() ) {
echo '<span class="sep">/</span> ';
if ( is_single() )
comments_popup_link( '0 comments', '1 comment', '% comments', 'post-comments' );
else
comments_number( '0 comments', '1 comment', '% comments' );
}
?>
</div>
<h2 class="post-title"><?php the_title(); ?></h2>
</a>
<?php endwhile; ?>
Step 2: In articles.php replace this line:
<?php get_template_part( 'content', get_post_format() ); ?>
with this one:
<?php get_template_part( 'articles' ); ?>
Not tested but it should work.

Wordpress: Recent post by tags

this is my content.php I am trying to list 2 diffrent tag on my home page. 5 post from each tag. Example 5 tags from tag:Football down of it 5 tags from tag:Basketball and here is my content.php Thanks in advance.
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php if ( has_post_thumbnail() ) : ?>
<div class="entry-thumb col-md-4 col-sm-4 col-xs-12">
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" >
<?php the_post_thumbnail('home-thumb'); ?>
</a>
</div>
<?php $has_thumb = "col-md-8 col-sm-8 col-xs-12"; ?>
<?php else : ?>
<?php $has_thumb = ""; ?>
<?php endif; ?>
<div class="entry-summary <?php echo $has_thumb; ?>">
<header class="entry-header">
<?php the_title( sprintf( '<h1 class="entry-title">', esc_url( get_permalink() ) ), '</h1>' ); ?>
</header><!-- .entry-header -->
<div class="post-info">
<?php if ( 'post' == get_post_type() ) : ?>
<?php areview_posted_on(); ?>
<?php endif; ?>
<span class="cat-link">
<?php
$category = get_the_category();
if($category[0]){
echo '<i class="fa fa-folder"></i>' . esc_attr($category[0]->cat_name) . '';
}
?>
</span>
<?php if(function_exists('yasr_get_overall_rating') && function_exists('cfs') && ($cfs->get('show_stars') == 1)) {
echo do_shortcode('[yasr_overall_rating]');
} ?>
</div>
<?php the_excerpt(); ?>
</div><!-- .entry-content -->
<div class="buttons-area">
<?php if ( function_exists('cfs') && ($cfs->get('button_link') !='' ) && ($cfs->get('button_title') !='') && ($cfs->get('button_index') == 1) ) : ?>
<?php echo esc_html($cfs->get('button_title')); ?>
<?php endif; ?>
<?php echo __('Read more', 'areview'); ?>
</div>
You should loop the tags and do a query for each one, and for each post insert your existing HTML, like this:
<?php
$tags = array(
'Football',
'Basketball'
);
foreach ($tags as $tag) {
query_posts(array(
'post_type' => 'post'
'posts_per_page' => 5,
'tax_query' => array(
'taxonomy' => 'post_tag',
'field' => 'name',
'terms' => $tag
)
));
if (have_posts()) {
while(have_posts()) {
the_post();
?>
///.... insert your existing code here
<?php
}
}
wp_reset_query();
}
?>
Just don't forget to insert your existing html instead of the ///.... insert your existing code here block.
Try this
<div class="relatedposts">
<h3>Related posts</h3>
<?php
$args=array(
'post_status' => 'publish',
'tag' => 'football,basketball', //Tag slug
'posts_per_page'=>4, // Number of related posts to display.
);
$my_query = new wp_query( $args );
while( $my_query->have_posts() ) {
$my_query->the_post();
?>
<div class="relatedthumb">
<a rel="external" href="<? the_permalink()?>"><?php the_post_thumbnail(array(150,100)); ?><br />
<?php the_title(); ?>
</a>
</div>
<?php }
wp_reset_query();
?>
</div>
Thank you everyone!! Finally I got it using this code:
get_header(); ?>
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<?php if ( have_posts() ) : ?>
<?php /* Start the Loop */ ?>
<div class="relatedposts">
<h3 class="widget-title">Football</h3>
<div class="decoration-bar"></div><br>
<?php
$args=array(
'post_status' => 'publish',
'tag' => 'football', //Tag slug
'posts_per_page'=>5, // Number of related posts to display.
);
$my_query = new wp_query( $args );
while( $my_query->have_posts() ) {
$my_query->the_post();
?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php if ( has_post_thumbnail() ) : ?>
<div class="entry-thumb col-md-4 col-sm-4 col-xs-12">
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" >
<?php the_post_thumbnail('home-thumb'); ?>
</a>
</div>
<?php $has_thumb = "col-md-8 col-sm-8 col-xs-12"; ?>
<?php else : ?>
<?php $has_thumb = ""; ?>
<?php endif; ?>
<div class="entry-summary <?php echo $has_thumb; ?>">
<header class="entry-header">
<?php the_title( sprintf( '<h1 class="entry-title">', esc_url( get_permalink() ) ), '</h1>' ); ?>
</header><!-- .entry-header -->
<div class="post-info">
<?php if ( 'post' == get_post_type() ) : ?>
<?php areview_posted_on(); ?>
<?php endif; ?>
<span class="cat-link">
<?php
$category = get_the_category();
if($category[0]){
echo '<i class="fa fa-folder"></i>' . esc_attr($category[0]->cat_name) . '';
}
?>
</span>
<?php if(function_exists('yasr_get_overall_rating') && function_exists('cfs') && ($cfs->get('show_stars') == 1)) {
echo do_shortcode('[yasr_overall_rating]');
} ?>
</div>
<?php the_excerpt(); ?>
</div><!-- .entry-content -->
<div class="buttons-area">
<?php if ( function_exists('cfs') && ($cfs->get('button_link') !='' ) && ($cfs->get('button_title') !='') && ($cfs->get('button_index') == 1) ) : ?>
<?php echo esc_html($cfs->get('button_title')); ?>
<?php endif; ?>
<?php echo __('Read more', 'areview'); ?>
</div>
</article>
<?php }
wp_reset_query();
?>
</div>
<center><h4 >---> More Posts <---</h4></center>
<div class="relatedposts">
<h3 class="widget-title">Basketball</h3>
<div class="decoration-bar"></div><br>
<?php
$args=array(
'post_status' => 'publish',
'tag' => 'basketball', //Tag slug
'posts_per_page'=>3, // Number of related posts to display.
);
$my_query = new wp_query( $args );
while( $my_query->have_posts() ) {
$my_query->the_post();
?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php if ( has_post_thumbnail() ) : ?>
<div class="entry-thumb col-md-4 col-sm-4 col-xs-12">
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" >
<?php the_post_thumbnail('home-thumb'); ?>
</a>
</div>
<?php $has_thumb = "col-md-8 col-sm-8 col-xs-12"; ?>
<?php else : ?>
<?php $has_thumb = ""; ?>
<?php endif; ?>
<div class="entry-summary <?php echo $has_thumb; ?>">
<header class="entry-header">
<?php the_title( sprintf( '<h1 class="entry-title">', esc_url( get_permalink() ) ), '</h1>' ); ?>
</header><!-- .entry-header -->
<div class="post-info">
<?php if ( 'post' == get_post_type() ) : ?>
<?php areview_posted_on(); ?>
<?php endif; ?>
<span class="cat-link">
<?php
$category = get_the_category();
if($category[0]){
echo '<i class="fa fa-folder"></i>' . esc_attr($category[0]->cat_name) . '';
}
?>
</span>
<?php if(function_exists('yasr_get_overall_rating') && function_exists('cfs') && ($cfs->get('show_stars') == 1)) {
echo do_shortcode('[yasr_overall_rating]');
} ?>
</div>
<?php the_excerpt(); ?>
</div><!-- .entry-content -->
<div class="buttons-area">
<?php if ( function_exists('cfs') && ($cfs->get('button_link') !='' ) && ($cfs->get('button_title') !='') && ($cfs->get('button_index') == 1) ) : ?>
<?php echo esc_html($cfs->get('button_title')); ?>
<?php endif; ?>
<?php echo __('Read more', 'areview'); ?>
</div>
</article>
<?php }
wp_reset_query();
?>
</div>
<center><h4 >---> More Posts <---</h4></center>
<div class="relatedposts">
<h3 class="widget-title">Handball</h3>
<div class="decoration-bar"></div><br>
<?php
$args=array(
'post_status' => 'publish',
'tag' => 'handball', //Tag slug
'posts_per_page'=>2, // Number of related posts to display.
);
$my_query = new wp_query( $args );
while( $my_query->have_posts() ) {
$my_query->the_post();
?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php if ( has_post_thumbnail() ) : ?>
<div class="entry-thumb col-md-4 col-sm-4 col-xs-12">
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" >
<?php the_post_thumbnail('home-thumb'); ?>
</a>
</div>
<?php $has_thumb = "col-md-8 col-sm-8 col-xs-12"; ?>
<?php else : ?>
<?php $has_thumb = ""; ?>
<?php endif; ?>
<div class="entry-summary <?php echo $has_thumb; ?>">
<header class="entry-header">
<?php the_title( sprintf( '<h1 class="entry-title">', esc_url( get_permalink() ) ), '</h1>' ); ?>
</header><!-- .entry-header -->
<div class="post-info">
<?php if ( 'post' == get_post_type() ) : ?>
<?php areview_posted_on(); ?>
<?php endif; ?>
<span class="cat-link">
<?php
$category = get_the_category();
if($category[0]){
echo '<i class="fa fa-folder"></i>' . esc_attr($category[0]->cat_name) . '';
}
?>
</span>
<?php if(function_exists('yasr_get_overall_rating') && function_exists('cfs') && ($cfs->get('show_stars') == 1)) {
echo do_shortcode('[yasr_overall_rating]');
} ?>
</div>
<?php the_excerpt(); ?>
</div><!-- .entry-content -->
<div class="buttons-area">
<?php if ( function_exists('cfs') && ($cfs->get('button_link') !='' ) && ($cfs->get('button_title') !='') && ($cfs->get('button_index') == 1) ) : ?>
<?php echo esc_html($cfs->get('button_title')); ?>
<?php endif; ?>
<?php echo __('Read more', 'areview'); ?>
</div>
</article>
<?php }
wp_reset_query();
?>
</div>
<center><h4 >---> More Posts <---</h4></center>
<?php else : ?>
<?php get_template_part( 'content', 'none' ); ?>
<?php endif; ?>
</main><!-- #main -->
</div><!-- #primary -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>

get post thumbnail image in wordpress and display in 3 coulmn

I am trying to display one particular category posts as a three column layout The problem I have is I am not sure how I can use for or forwach to loop the display of each post thumbnail so whn it comes more than three I can use one_thrid_last. css class.
<?php while ( have_posts() ) : the_post(); ?>
<?php if (is_category('actress-gallery') ):?>
<?php if ( function_exists("has_post_thumbnail") && has_post_thumbnail() ) : ?>
<div class="one_fourth_last">
<a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'tie' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark">
<?php echo $image_url = wp_get_attachment_image( get_post_thumbnail_id($post->ID) , 'thumbnail' ); ?>
<h2><?php the_title(); ?></h2>
</a>
</div><!-- post-thumbnail /-->
<?php endif; ?>
<div class="wrapper" style="width:800px; height:auto;">
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<?php if ( has_post_thumbnail() ) { ?>
<div class="image-wrapper" style=" width:250px; height:300px;" >
<?php the_title();?>
<?php the_content();?>
<?php the_post_thumbnail(); ?>
</div>
<?php } endwhile; endif; ?>
</div>
<div class="wrapper" style="width:750px; height:700px;">
<?php while (have_posts()) : the_post(); ?>
<?php if ( has_post_thumbnail() ) { ?>
<div style="width:250px; height:300px;" >
<?php the_title();?>
<?php the_post_thumbnail(); ?>
</div>
<?php } endif; ?>
</div>
You can use a $count variable and check for the 3rd thumbnail.
<?php if ( have_posts() ) : ?>
<?php $count = 1; ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php if ( has_post_thumbnail() ) : ?>
<?php if ($count % 3 == 0) : ?>
<div class = "one_third_last">
<?php else : ?>
<div class = "other_class">
<?php endif; ?>
<?php the_title();?>
<?php the_content();?>
<?php the_post_thumbnail(); ?>
</div>
<?php endif; ?>
<?php $count++; ?>
<?php endwhile; ?>
<?php endif; ?>

Display the trash posts instead of published posts?

I want to display the posts of post_status="trash" but not post_status="publish". In short, the posts in trash should get displayed on the site. For how long the trash posts would be available in trash? Any help would be appreciated.
index.php
<?php
// show all coupons and setup pagination
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts(array(
'post_type' => APP_POST_TYPE,
'ignore_sticky_posts' => 1,
'paged' => $paged
));
?>
<?php get_template_part('loop', 'coupon'); ?>
loop-coupon.php
<?php while (have_posts()) : the_post(); ?>
<?php appthemes_before_post(); ?>
<div <?php post_class('item'); ?> id="post-<?php echo $post->ID; ?>">
<div class="item-holder">
<div class="item-frame">
<div class="store-holder">
<div class="store-image">
<img height="89" width="110" src="<?php echo clpr_store_image($post->ID, APP_TAX_STORE, 'term_id', '110', null); ?>" alt="" />
</div>
<div class="store-name">
<?php echo get_the_term_list($post->ID, APP_TAX_STORE, ' ', ', ', ''); ?>
</div>
</div>
<?php clpr_vote_box_badge($post->ID, $the_trans); ?>
<div class="item-panel">
<?php clpr_coupon_code_box(); ?>
<div class="clear"></div>
<?php appthemes_before_post_title(); ?>
<h1><?php if (mb_strlen(get_the_title()) >= 87) echo mb_substr(get_the_title(), 0, 87).'...'; else the_title(); ?></h1>
<?php appthemes_after_post_title(); ?>
<?php appthemes_before_post_content(); ?>
<p class="desc"><?php echo mb_substr(strip_tags($post->post_content), 0, 200).'... ';?><a class="more" href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'View the %s coupon page', 'appthemes' ), the_title_attribute( 'echo=0' ) ); ?>"><?php _e('more ››', 'appthemes') ?></a></p>
<?php appthemes_after_post_content(); ?>
</div> <!-- #item-panel -->
</div> <!-- #item-frame -->
</div>
</div>
<?php appthemes_after_post(); ?>
<?php appthemes_after_endwhile(); ?>
<?php appthemes_loop_else(); ?>
<h3><?php _e('Sorry, no coupons found', 'appthemes'); ?></h3>
`
Try adding this before your loop
query_posts($query_string. '&post_status=trash');

Resources