• Resolved Jill Anderson

    (@jillbalkus)


    Hi! Great plugin! I was wondering if there’s a way to limit the comments the plugin is pulling to a certain page?

Viewing 9 replies - 1 through 9 (of 9 total)
  • Hi,

    Thanks! There isn’t a way to do that directly, but you could hook into the code which fetches the comments from the database. I can send you a PHP code snippet if interested. Let me know.

    Kind regards,
    Andy

    Thread Starter Jill Anderson

    (@jillbalkus)

    Yes, please send the code. I really appreciate it!

    
    add_filter( 'better_recent_comments_comment_args', function( $args ) {
        // Limit comments to a specific post ID
        $args['post_id'] = 123;
        return $args;
    } );
    

    You’ll need to replace ‘123’ with the actual ID of the post/page. You could also try using get_the_ID() to get the current page ID but I’m not sure that will work with caching. You could try it though.

    • This reply was modified 4 years, 1 month ago by Andy Keith.
    • This reply was modified 4 years, 1 month ago by Andy Keith.
    Thread Starter Jill Anderson

    (@jillbalkus)

    Fabulous! Thank you!!

    Hi, Jill ( @jillbalkus ).

    Thanks for your reply. I’m glad we could help!

    Additionally, since our plugin doesn’t have an option that allows you to limit the displayed comments to only be pulled from a certain page, I have added it to our feature request list so that we can track the amount of demand for it. We will let you know if we add this to a future version of the plugin.

    In the meantime, I’m sorry that this isn’t possible. I hope the custom PHP code snippet that we provided gets the job done for now.

    Should you have any other questions, please let us know.

    If it isn’t too much trouble, I’d love it if you would please be so kind as to add a review for Better Recent Comments at https://www.ads-software.com/support/plugin/better-recent-comments/reviews/ .

    Many thanks and keep safe,

    Thread Starter Jill Anderson

    (@jillbalkus)

    The PHP code worked perfectly!

    Brilliant! Thanks for letting us know, Jill ( @jillbalkus ) and well done in applying it to your site.

    ukbestrong

    (@ukbestrong)

    This is a brilliant snippet! Worked perfectly for me too – thank you ??

    E.J. Padero

    (@barn2support)

    Hi, @ukbestrong .

    Thanks for chiming in and for using our Better Recent Comments plugin. Fantastic! I’m glad we could help!

    Should there be anything else that we may assist you with, just let us know.

    Best regards and keep safe.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Limit to a specific page?’ is closed to new replies.