[resolved] Sort custom post type by rating score (2 posts)

  1. darlinncordova
    Posted 1 year ago #

    hi i did this code and works fine but i cant get all "juegos posts" just posts with rating , how can i get rating and no rating list posts.

    $paged = get_query_var('paged') ? get_query_var('paged') : 1;
     $args = array(
    	'post_type' => 'juegos',
    	'post_parent' => 0,
    	'meta_key' => 'ratings_average',
    	'paged'=> $paged,
    	'posts_per_page' => 5
    $the_query = new WP_Query( $args );

    [Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been damaged by the forum's parser.]


  2. Lester Chan
    Plugin Author

    Posted 1 year ago #

    Sorry, you can't get posts without ratings, there is a limitation with the WP_Query and custom post field.

    The only manual way I can think of is manually create the custom post field "ratings_average" for post that have no ratings.

    The reason why it does not have those fields I am guessing is because it was created before WP-PostRatings was activated. Once WP-PostRatings is activated, upon every post, it will create the custom post field with 0 as the value.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic


No tags yet.