WordPress.org

Ready to get started?Download WordPress

Forums

Post Views Count
[resolved] how to do a "query_post" with the meta key ? (6 posts)

  1. Elessar_Gu
    Member
    Posted 1 year ago #

    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/

  2. Julio Potier
    Member
    Plugin Author

    Posted 1 year ago #

    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

  3. Elessar_Gu
    Member
    Posted 1 year ago #

    Fast answer, and problem solved. Awesome :)

    Thanks !

  4. andersonnarciso
    Member
    Posted 1 year ago #

    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)

  5. Julio Potier
    Member
    Plugin Author

    Posted 1 year ago #

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

  6. andersonnarciso
    Member
    Posted 1 year ago #

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

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.