• Im having major problems trying to figure out what would be the best method and how to actually do this. I will quickly explain what I want to do and what I currently have:

    What I want to do:
    Ok, so I have a column of posts (thumb + title) and above the first post I was hoping to have a filter menu, which would load the next bunch of posts.

    Week | Month | All-time

    POST THUMB
    Title

    POST THUMB
    Title

    POST THUMB
    Title

    To get the most viewed posts, Im currently using this:`// function to display number of posts.

    function getPostViews($postID){
        $count_key = 'post_views_count';
        $count = get_post_meta($postID, $count_key, true);
        if($count==''){
            delete_post_meta($postID, $count_key);
            add_post_meta($postID, $count_key, '0');
            return "0 View";
        }
        return $count.' Views';
    }
    
    // function to count views.
    function setPostViews($postID) {
        $count_key = 'post_views_count';
        $count = get_post_meta($postID, $count_key, true);
        if($count==''){
            $count = 0;
            delete_post_meta($postID, $count_key);
            add_post_meta($postID, $count_key, '0');
        }else{
            $count++;
            update_post_meta($postID, $count_key, $count);
        }
    }

    I did want to make the filter using javascript, so it would work something like this:

    https://listjs.com/examples/standard.html

    Any help or advice would be great, thanks

  • The topic ‘Sort/filter posts on most viewed page?’ is closed to new replies.