WordPress.org

Ready to get started?Download WordPress

Forums

Electric Studio Auto Post Expire
Sort Category by Expiry date? (2 posts)

  1. kendawes
    Member
    Posted 1 year ago #

    Is there a way to sort a category page so that posts are displayed with the soonest expiry date is at the top?

    Thanks!

    http://wordpress.org/extend/plugins/electric-studio-auto-expire-post/

  2. Gabor Javorszky
    Member
    Posted 1 year ago #

    Hiya!

    Yes, in your WP_Query, add sorting by meta_value_num. The meta key is es_ape_expiry. Basically that's a timestamp, so the lowest value is the one to expire soon. Don't forget to add post_status.

    This should solve it:

    $args = array(
        'post_status' => 'publish',
        'meta_key' => 'es_ape_expiry',
        'order' => 'ASC',
        'oderby' => 'meta_value_num'
    );
    
    $new_posts = new WP_Query( $args );

    Gabor

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.