0

I'm using the WordPress plugin 'I recommend this', it allows people to 'like' posts. The value is stored as a meta key, which we can query to generate a 'most recommended' page.

Plugin -> http://wordpress.org/support/plugin/i-recommend-this

The loop.

<?php 
        query_posts('&orderby=meta_value&meta_key=_recommended');
        if (have_posts()): while (have_posts()) : the_post();
    ?>
        <article <?php post_class('item-post block'); ?> id="post-<?php the_ID(); ?>">


         <h2><?php the_title(); ?></h2>
        </article>


    <?php endwhile; ?>
    <?php endif; ?>

This works, it finds the most recommended posts.

Two questions.

  1. How do I limit the posts returned to a date range of say, the last 3 months?

  2. In a similar vein, how could I then have a button for 'Most popular this week' that'd allow users to see a filtered result of posts from the last 7 days?

1 Answer 1

0

The recent addition of date query makes it possible to use very elaborate conditions, see Date Parameters documentation in Codex.

As for outputting certain set of posts the simplest way might be to create dedicated page with custom page template for it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.