• Resolved tbmarkus

    (@tbmarkus)


    Hello,

    I like your plugin pretty much!

    But there’s one thing I can’t get done. If I am visiting my site with ?v_sortby=views&v_orderby=desc after the index.php – It shows me ALL content sorted by most viewed.

    Now I want the site only showing posts from one special category. How can I realise this?

    I think I’ve to change something in the code below. But I am not an php expert, so I thought you can help me?

    ### Function: Modify Default WordPress Listing To Make It Sorted By Post Views
    function views_fields($content) {
    global $wpdb;
    $content .= “, ($wpdb->postmeta.meta_value+0) AS views”;
    return $content;
    }
    function views_join($content) {
    global $wpdb;
    $content .= ” LEFT JOIN $wpdb->postmeta ON $wpdb->postmeta.post_id = $wpdb->posts.ID”;
    return $content;
    }
    function views_where($content) {
    global $wpdb;
    $content .= ” AND $wpdb->postmeta.meta_key = ‘views'”;
    return $content;
    }
    function views_orderby($content) {
    $orderby = trim(addslashes(get_query_var(‘v_orderby’)));
    if(empty($orderby) || ($orderby != ‘asc’ && $orderby != ‘desc’)) {
    $orderby = ‘desc’;
    }
    $content = ” views $orderby”;
    return $content;
    }

    https://www.ads-software.com/plugins/wp-postviews/

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Modify Default WordPress Listing To Make It Sorted By Post Views AND category?’ is closed to new replies.