• Resolved YuriV

    (@yuriv)


    I guess it’s better to open a new thread for this, since this issue is not resolved.

    We want the archive pages on our blog to display the toprated content first. To achieve this, we use this code before the loop:

    <?php query_posts($query_string . '&meta_key=Likes&orderby=meta_value&meta_type=numeric&order=DESC'); ?>
    

    There’s one major issue with this. It returns top rated posts first, but hides all posts with no likes. This makes no sense. How can those posts get votes when they are not visible…

    I found out we can select the extra field ‘Likes’ in WordPress. We can manually add ‘0’ to new posts (or posts with no likes). Once we’ve done that the post is also visible on the archive pages with top rated content. But of course it’s not workable to go through all our posts and manually add ‘0’. The plugin should do this.

    Could you take a look at this? Seems like quite a big bug. Thanks in advance.

    In the meantime we will remove the code before the loop and show posts in the normal WordPress-order.

    • This topic was modified 7 years, 6 months ago by YuriV.
    • This topic was modified 7 years, 6 months ago by YuriV.
Viewing 1 replies (of 1 total)
  • Plugin Author LikeBtn

    (@likebtn)

    Please try to use the following code:

    <?php
    	$args  = array(
    		'orderby' => 'meta_value',
    		'order' => 'DESC',
    		'meta_query' => array(
    			'relation' => 'OR',
    			 array(
    				'key' => 'Likes',
    				'compare' => 'NOT EXISTS',
    				'type' => 'numeric'
    			 ),
    			 array(
    				'key' => 'Likes',
    				'compare' => 'EXISTS',
    				'type' => 'numeric'
    			 )
    		 )
    	);
    	$args = array_merge( $args , $wp_query->query );
    	query_posts($args);
    ?> 
Viewing 1 replies (of 1 total)
  • The topic ‘Posts with no votes are NOT VISIBLE…’ is closed to new replies.