Support » Plugins and Hacks » [Resolved] Use recommended posts within wp_query?

[Resolved] Use recommended posts within wp_query?

  • KS Web Designer


    Thanks for this great, plugin it works brilliantly. I was just wondering, is it possible to access the number of recommendations a post has via a wp_query? Say if I wanted to order the treturned posts by number of recommendations or exclude any with less than ‘x’ recommendations?



Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Harish Chouhan



    Yes it is. However would require some testing.

    Have you checked this http://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters?

    In wp_query you can sort using a custom meta key. i am afraid I would not be able to provide you with a complete code, but you can refer to http://wordpress.org/support/topic/meta-value-_recommended?replies=9 for some idea.

    				// Create a new filtering function that will add our where clause to the query
    				function filter_where( $where = '' ) {
    				    // posts in the last 30 days
    				    $where .= " AND post_date > '" . date('Y-m-d', strtotime('-380 days')) . "'";
    				    return $where;
    				add_filter( 'posts_where', 'filter_where' );
    				$featuredPosts = new WP_Query( array(
    				'posts_per_page' => 33,
    			    'orderby' => 'meta_value_num',
    			    'order' => DESC
    				) ); 
    				remove_filter( 'posts_where', 'filter_where' ); ?>
    				<?php if ( $featuredPosts->have_posts() ) : ?>
    				<?php while ( $featuredPosts->have_posts() ) : $featuredPosts->the_post(); ?>
    				<article <?php post_class('item-post block'); ?> id="post-<?php the_ID(); ?>">
    					<?php the_title(); ?>
    			</article> <!-- end div post -->
    				<?php endwhile; wp_reset_query(); ?>
    				<?php endif; ?>


    Plugin Author Harish Chouhan


    Thank you for sharing the code @andy999

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Resolved] Use recommended posts within wp_query?’ is closed to new replies.