[Resolved] [Feature Request] Detect and cooperate with plugin Post Views Counter

Please login to receive premium support.

Support for the free plugin can be found here.

Home Forums Pro Support [Feature Request] Detect and cooperate with plugin Post Views Counter

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #28469
    Adam
    Participant

    It would be really cool if WPSP could detect the presence of the Post Views Counter plugin and make use of the data it collects. That way, one could have an “Order by” setting of “Page Views”, i.e. show the most popular content on the site.

    #28475
    elvin
    Moderator

    Hi there,

    While this is interesting, it won’t be necessary.

    When adding features, we have to consider if many users request for it to make the addition worth the effort as adding more code potentially makes WPSP less lightweight.

    If you want to add the post view counter, you can just hook it into the WPSP loops.

    If you wish to use the post view counter value, you can use its meta value for the orderby sorting with filters or shortcode.

    Example/s:

    Via Shortcode:
    [wp_show_posts id="1477" settings="meta_key=post_views_count&orderby=meta_value_num&order=ASC"]

    Via Filters:

    add_filter( 'wp_show_posts_shortcode_args', function( $args, $settings ) {
        if ( 123 === $settings['list_id'] ) {
            $args['meta_query'] => array(
                array(
                    'key' => 'post_views_count',
                    'orderby' => 'meta_value_num',
                    'order' => 'DESC',
                )
            );
        }
    
        return $args;
    } );
    #28502
    Adam
    Participant

    @elvin, thanks. That’s very helpful!

    #28524
    elvin
    Moderator

    No problem. 🙂

    #32421
    Lee
    Participant

    Thank you! This helped me, too. Can I recommend this instruction be added to the WP Show Posts documentation along with a list of meta keys used by popular social share / post likes plugins e.g. Grow (nee Social Pug) uses dpsp_networks_shares_total.

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.