• Resolved wotpstore

    (@wotpstore)


    Great plugin Mr Keith.

    I have been able to use your shortcode to customize to my client’s needs. Just need 2 more things. I need to display specific comment IDs, and in other cases recent comments from one product ID.

    Please let me know how we can do this.

    Christian

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

    Sorry for the slow reply.

    To display specific comments only, you would need to set “comment__in” on the array passed to get_comments(). This is in Better_Recent_Comments_Util, line 78. E.g. ‘comment__in’ => array( 24, 35 ).

    To display comments from one product (i.e. post) then set the “post__in” parameter.

    Andy

    Thread Starter wotpstore

    (@wotpstore)

    Hi Andy,

    Thanks for the response. Will this specify the display of only one comment or comments from one product? I don’t understand how to add this code to the plugin without breaking it. Would you please help me out with that? And I’d need to know what line to add to the shortcode too.

    Christian

    There’s no shortcode option to set this. You’d need to add the code manually.

    Modify the comment args in Better_Recent_Comments_Util:

    Change the get_comments args on line 78 to this:

    $comments = get_comments( array(
       'number' => $number,
       'status' => 'approve',
       'type' => apply_filters( 'better_recent_comments_comment_type', 'comment' ),
       'post__in' => 23 // set your product ID here
    ) );

    And to select specfic comments only:

    $comments = get_comments( array(
       'number' => $number,
       'status' => 'approve',
       'type' => apply_filters( 'better_recent_comments_comment_type', 'comment' ),
       'comment__in' => array( 45, 56) // set your comment IDs here
    ) );
    • This reply was modified 8 years, 1 month ago by Andy Keith.
    Thread Starter wotpstore

    (@wotpstore)

    Andy thank you for spelling it out for me. I’m breaking the code. Can we continue with private message?

    Thread Starter wotpstore

    (@wotpstore)

    Ok, so editing the right file would be better. lol I forund the file you referred to and line 78. I replaced the code with the second option you gave me, and replaced the (45,46) with an actual comment id number. no bad header now :P.

    How do I call up the plugin now since I can’t use shortcode? I tried [better_recent_comments] but it just shoes that string of text and not the comment content.

    Just use the shortcode as normal – the shortcode uses the code that you’ve modified so that should work.

    Thread Starter wotpstore

    (@wotpstore)

    I have used the shortcode as before, with and without parameters, it only displays exactly the text I have typed. As in:

    [better_recent_comments number=”1″ post_status=”publish,private” format=”{comment} {post}” excerpts=false]

    or

    [better_recent_comments]

    Shortcode does not work as normal after modifying the comment arguments in Better_Recent_Comments_Util.php on line 78 to this:

    $comments = get_comments( array(
    ‘number’ => $number,
    ‘status’ => ‘approve’,
    ‘type’ => apply_filters( ‘better_recent_comments_comment_type’, ‘comment’ ),
    ‘comment__in’ => array( 45, 56) 768// set your comment IDs here
    ) );

    And also when I changed it to this:

    $comments = get_comments( array(
    ‘number’ => $number,
    ‘status’ => ‘approve’,
    ‘type’ => apply_filters( ‘better_recent_comments_comment_type’, ‘comment’ ),
    ‘comment__in’ => array( 769) // set your comment IDs here
    ) );

    Just in case you meant IN the brackets replacing ( 45, 56) when you said ‘here’. Either way, I don’t get anything different than what I’ve typed displayed.

    Sorry I can’t provide any more free support for this. I would recommend Codeable:

    https://codeable.io/?ref=qGT4L

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘How does one specify comment ID or product ID?’ is closed to new replies.