John Timson Rimeišis
John Timson Rimeišis

Reputation: 23

Show post with enough of upvotes on homepage

So I'm using wordpress with a updownupdown plugin (plugin for upvoting/downvoting posts). What I am trying to do is to show post with ,let's say at least 10 upvotes, on the homepage and hide the post with not enough points.

I tried to us this code in index.php

if (have_posts()) :
    while (have_posts()) : the_post();
        if (up_down_post_votesscore(  get_the_ID()) > 10){
        //content
        }
    endwhile;
endif;

and it kind of works, it hides all the post with less than 10 upvotes, but it doesn't put all the qualifying posts in one page (homepage has a pagination), so let's say there is 2 pages with 5 posts and there is 2 posts in each page with needed amount of upvotes, so instead of putting those 4 posts in one page, it shows only 2 qualifying post in each page.

Upvotes: 2

Views: 92

Answers (1)

Robert Lee
Robert Lee

Reputation: 1561

Sounds like your posts retrieval is limited. You may want to change how many posts are obtained using:

query_posts( 'posts_per_page=20' );

reference: http://codex.wordpress.org/Function_Reference/query_posts

or do something like this if you're using get_posts:

$args = array(
'posts_per_page'  => 20
);
get_posts( $args );

Reference: http://codex.wordpress.org/Template_Tags/get_posts

Upvotes: 2

Related Questions