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

    (@hchouhan)

    @ks,

    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.

    <?php 
    
    				// 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,
    			    'meta_key'=>'_recommended',
    			    '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; ?>

    Enjoy!

    Plugin Author Harish Chouhan

    (@hchouhan)

    Thank you for sharing the code @andy999

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