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

    (@dfactory)

    It is not stored in custom field.

    But the native WP Query can handle the orderby post_views parameter in cas you need it.

    Is it possible for ‘orderby’ => ‘post_views’ to work with get_recent_posts() ?

    function get_recent_posts($cat_slug, $num, $offset = null){
        $args = array(
          'numberposts' => $num,
          'category' => get_category_by_slug($cat_slug)->cat_ID,
          'order' => 'DESC',
          'offset' => $offset,
          'post_type' => 'post',
          'post_status' => 'publish',
          'orderby'     => 'post_views',
          'meta_query' => array(
            array(
              'key' => '_thumbnail_id',
              )
            )
          );
        return wp_get_recent_posts( $args );
      }
    Plugin Author dFactory

    (@dfactory)

    It should work already. The wp_get_recent_posts() is nothing more than the get_posts() function wrapper.

    BUT, you have to set “suppress_filters” parameter to false.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Post Views Counter – Custom Field’ is closed to new replies.