Support » Plugin: Post Views Count (Support caching plugins!) » [Plugin: Post Views Count] how to do a "query_post" with the meta key ?

  • Resolved Elessar_Gu

    (@elessar_gu)


    Hi,

    I just installed the plugin, and I’m trying to use “query_post” in my index.php to sort the most viewed posts.

    I’m not sure I got the right name for the meta_key to use.

    This is my query (who doesn’t work):

    query_posts(array($args,'post_type' => 'videos','meta_key' => 'baw_count_views_meta_key','orderby' => 'meta_value','order' => 'DESC','showposts' => 4) );
    
    get_template_part( 'loop', 'index' );

    ($args includes ‘post_status’ and ‘paged’).
    ‘video’ is a custom type.

    Am I missing something ? I’m new at WP (and PHP actually). Any help would be great. Thanks 🙂

    (Sorry if my English isn’t quite right, it’s not my native language – Frenchie here – :p)

    http://wordpress.org/extend/plugins/baw-post-views-count/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Julio Potier

    (@juliobox)

    Hello Elessar (je suis français aussi ;p)

    “baw_count_views_meta_key” is a filter name for developpers needs, try “_count-views_all” instead 😉

    See you and give me a feedback on this issue

    Thread Starter Elessar_Gu

    (@elessar_gu)

    Fast answer, and problem solved. Awesome 🙂

    Thanks !

    Why for me dont work ;/

    <?php
     $args = array(
         'post_status' => 'publish',
         'post_type' => 'djs',
         'meta_key' => '_count-views_all',
         'orderby' => 'meta_value',
         'order' => 'DESC'
      );
      $ranking = 0;
    
      ?>
    
        <?php query_posts($args) ?>
        <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); $ranking++; ?>

    Dont show nothing, but.. i remove ‘meta_key’ => ‘_count-views_all’, show the posts.. (sorry bad english)

    Plugin Author Julio Potier

    (@juliobox)

    Hello, do not ask a question in a resolved post, create a new one.
    This is a basic rule.

    And it is a basic rule also avoid posts with the same content.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Plugin: Post Views Count] how to do a "query_post" with the meta key ?’ is closed to new replies.