• Resolved The Three

    (@3wwwgr)


    On page refresh +1 value is added to a custom field of each post:

    on functions.php:

    function wpb_set_post_views($postID) {
        $count_key = 'wpb_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);
        }
    }
    remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);

    on posts:

    wpb_set_post_views(get_the_ID());

    now how i can get the most popular of one category by combine the flexible posts widget & this costum field?

    https://wordpress.org/plugins/flexible-posts-widget/

Viewing 1 replies (of 1 total)
  • Plugin Author DaveE

    (@dpe415)

    Hi The Three,

    You’d need to filter the query arguments using your custom meta data essentially writing your own query to accomplish this. There is a filter in place to allow this kind of functionality: $args = apply_filters( 'dpe_fpw_args', $args );

    Cheers!

Viewing 1 replies (of 1 total)

The topic ‘most popular by custom field value’ is closed to new replies.