How to Move "Expired" Posts to Last Page in Wordpress

Discussion in 'HTML & Website Design' started by leeannax, Jan 10, 2013.

  1. #1
    I have a deal/coupon site: www.pricecharmer.com and was trying to figure out a way to move "Expired" deals to the last page and keep unexpired deal posts on the home page and first few pages.

    I know I should have chosen a different theme, but I like this one and want to make it work by tweaking coding and etc.

    I was looking at other deal sites for inspiration and even having the ability to "shrink" or strikethrough an expired post might work.

    Just looking for organization ideas or thoughts.

    Do you think this website is unorganized and hard to navigate through?
     
    leeannax, Jan 10, 2013 IP
  2. T-train

    T-train Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Assuming this site is using a database. Your going to need to rewrite your query so it selects newer tables first. This is actually really easy. But I wouldn't be able to help without seeing the actual query used to select each new item.
     
    T-train, Jan 10, 2013 IP
  3. leeannax

    leeannax Greenhorn

    Messages:
    33
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    18
    #3
    Thanks for your help! Looking for the query in main index, I see this:

    <?php get_header(); ?>

    <div id="content">

    <div id="boxes">

    <div id="loading"></div>

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>

    <div class="item" >

    <header>

    <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php if(the_title( '', '', false ) !='') the_title(); else _e( 'View Post', 'pinblue' ); ?></a></h2>

    </header>

    <section class="post_content">
    <div class="thumb">
    <?php
    if ( has_post_thumbnail()) : ?>

    <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php echo the_post_thumbnail( 'medium' ); ?></a>

    <?php else : ?>

    <?php $postimgs =& get_children( array( 'post_parent' => $post->ID, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'orderby' => 'menu_order', 'order' => 'ASC' ) );
    if ( !empty($postimgs) ) :
    $firstimg = array_shift( $postimgs );
    $my_image = wp_get_attachment_image( $firstimg->ID, 'medium' );
    ?>

    <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php echo $my_image; ?></a>

    <?php else : ?>

    <img src="<?php echo get_template_directory_uri(); ?>/library/images/noimage.png" />
    <?php endif; ?>
    <?php endif; ?>
    </div>
    </section> <!-- end article section -->

    <footer>

    <p class="cat"><?php _e("Filed Under", 'pinblue'); ?> <?php the_category(', '); ?></p>

    </footer> <!-- end article footer -->

    </div>


    <?php endwhile; ?>


    <?php endif; ?>


    </div>
    </div> <!-- end #content -->

    <?php if (function_exists("pinblue_pagination")) {
    pinblue_pagination();
    } elseif (function_exists("pinblue_content_nav")) {
    pinblue_content_nav( 'nav-below' );
    }?>


    <?php get_footer(); ?>
     
    leeannax, Jan 11, 2013 IP
  4. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #4
    The only way I can think of to do what you want automatically would be to have an additional date field in the table - expire_date. Then do your SELECT with expire_date DESC added to the WHERE clause. (There might be a plugin that does or simulates that.)
     
    Rukbat, Jan 11, 2013 IP
  5. China J

    China J Member

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #5
    Based on the url you gave, it's a bit difficult to tell whats going on. You have older posted items at the beginning, recent posted items in the middle, and back to older posted items at the end. With that being said, it seems that there is already a setting to determine this value in the deals plugin? If not, a plugin that I use to move expired posts is called "Post Expirator" in the Wordpress plugin directory here >>>http://wordpress.org/extend/plugins/post-expirator/screenshots/

    However, it sets them as drafts when expired. I usually just reset the dates on all drafts to something older though. I don't like it but it's the closest thing right now. Maybe a feature request to auto add a new post date in the past. Hope this helps :)
     
    China J, Jan 14, 2013 IP
  6. leeannax

    leeannax Greenhorn

    Messages:
    33
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    18
    #6
    thanks for all the help! i'm going to try both suggestions and see what works for me.

    What you're seeing China J is a setting I found where I can move any post to the front by just checking a box in the post. That seems to be working for now.
     
    leeannax, Jan 14, 2013 IP
    Textlinksguru likes this.