WordPress.org

Ready to get started?Download WordPress

Forums

WP-PostViews
WP_Query - how to use it? (4 posts)

  1. O_Breda
    Member
    Posted 1 year ago #

    Hello,

    I want to show in the sitebar of http://calatoriainimii.net/ a list of the most popular posts.

    I want to make a modified version of WP_Query.

    <?php
    $et_popular_query = new WP_Query( apply_filters( 'et_popular_query_args', array(
    'posts_per_page' => 3,
    'post_status'=> 'publish',
    'v_sortby' => 'views',
    'v_orderby' => 'desc'
    
    ) ) );
    if ($et_popular_query->have_posts()) : while ($et_popular_query->have_posts()) : $et_popular_query->the_post();
    ?>

    Unfortunately, this doesn't work.

    Any ideas?

    http://wordpress.org/extend/plugins/wp-postviews/

  2. shansta
    Member
    Posted 1 year ago #

    This is how I do it.

    $wp_query = new WP_Query();
    $wp_query->query('showposts=NUMBER&v_sortby=views&v_orderby=desc');
    $topviews = 1;
    
    if($wp_query->have_posts()) : while($wp_query->have_posts()) : $wp_query->the_post(); ?>
    
    blah blah 
    
    <?php  endwhile; endif; $topviews++; ?>
  3. O_Breda
    Member
    Posted 1 year ago #

    Thank you so much for the kind reply, shansta!

  4. Socrat1s
    Member
    Posted 1 year ago #

    Hi, i'm trying to use a "Custom Query String" to show up the posts by the most viewed..

    I ended up with this line but it doesn't work..

    $query = new WP_Query( array ( 'post_type' => 'most_popular', 'sortby' => 'get_most_viewed', 'orderby' => 'meta_value_num', 'order' => 'ASC' ) );

    ..any suggestions?

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.