• Resolved pheisholt

    (@pheisholt)


    I’m using NextGEN Gallery to organize my images in photo albums. Visitors may add comments to the photos, and the comments appear in WP Control Panel | Comments.
    But they do not appear in my comment widget (Better Recent Comments). The same thing happens if I use the standard WP Comments widget.

    I assume that there somehow is a difference between regular post comments and the NextGEN image comments.

    Has anyone had the same experience? Anyone know if there is a work around?

Viewing 15 replies - 1 through 15 (of 36 total)
  • Hi, @pheisholt.

    I’m sorry to hear you’re having difficulty with displaying Better recent Comments in your photo albums created by the NextGEN Gallery plugin by Imagely on your site. Thanks for getting in touch so we can help you sort it out.

    I appreciate the details you’ve included about investigating this on your end. As the default/standard WordPress comments (from which our plugin pulls the exact same comments data) also do not appear/display in your NextGEN Gallery photo albums, I agree with you that the latter may be adding/storing a type of comments of its own.

    That being said, I suggest you contact NextGEN Gallery support and relay this information to them, to ask if they could kindly assist.

    I hope this makes sense and helps point you in the right direction. Please let me know how it goes, and if there might be anything else that we may assist you with.

    Best regards and keep safe,

    I’ll mark this as resolved for now. Thanks.

    Thread Starter pheisholt

    (@pheisholt)

    Thanks for the response.

    I’ve been in touch with Imagely and suggested that they consider creating a separate widget that will display the NGG image comments.

    However, I still don’t understand the difference between these two types of comments – especially since they appear jointly in WP Control Panel | Comments. So it appears that WP is able to identify the NGG comments and list them alongside regular post comments.

    Thread Starter pheisholt

    (@pheisholt)

    I’d like to reopen this case, since it turns out to more serious than I initially thought.

    One thing is not being able to show media comments using Better Recent Comments (BRC). What I now have discovered is that media comments (in this case NextGEN Gallery image comments) are taken into account when BRC determines the x number of newest comments.

    So if I set BRC up to show the 5 latest comments, and the 5 most recent comments in the wp_comments database table are media comments (=NGG image comments), the BRC widget won’t display any comments at all. If the 4 most recent comments are media comments, BRC will display 1 comment only etc.

    So it would be nice if BRC at least would limit its scope to the taxonomies it’s able to display, when determining the most recent comments.

    Hi,

    Thanks for getting in touch. Could you let me know how you support adding comments for images in the NextGen Gallery plugin? I’m not aware of this feature and haven’t come across it in testing.

    Kind regards,
    Andy

    Thread Starter pheisholt

    (@pheisholt)

    Hi

    NextGEN Gallery’s lightbox includes an option to enable comments. It’s a regular comment field with a submit button. You can see an example here: NextGEN Gallery Lightbox with comment field

    The comments are stored in the wp-comments database table alongside all other comments (post, page etc.). And that’s obviously where the problem begins.

    In the wp_comments table there doesn’t seem to be anything to distinguish between comments from different post types or from different taxonomies. But by joining the wp-comments and the wp-posts tables, one can determine which is which.

    This SQL statement will separate the NGG comments (post_type=photocrati-comments) from other comments (post_type=post | page |...)

    SELECT DISTINCT ID, post_title, post_password, comment_ID, comment_post_ID
    , comment_author, comment_date_gmt, comment_approved, comment_type
    , comment_author_url, post_type, SUBSTRING(comment_content,1,30) AS com_excerpt 
    FROM wp_comments 
    LEFT OUTER JOIN wp_posts ON (wp_comments.comment_post_ID = wp_posts.ID) 
    WHERE comment_approved = "1" AND comment_type = "" AND post_password = "" 
    ORDER BY comment_date_gmt DESC LIMIT 10;

    Hope this may be of some help.

    I can send you screen shots, if you provide an email address or some other way to convey them to you.

    Hi, @pheisholt.

    Thank you for your reply. This is to acknowledge the information you’ve shared, which I have relayed to our developers. I or another member of our team will let you know as soon as we have an update.

    Thanks in advance for your patience and understanding.

    Thread Starter pheisholt

    (@pheisholt)

    Excellent, thanks!

    Hi,

    Thanks for your patience. I don’t have access to NextGEN Pro/Plus to test the comments feature, but my best guess would be that NextGEN is using a different comment type for the comments it stores in the wp_comments table.

    In your wp_comments table could you check the comment_type field for the lightbox comments?

    Our plugin (and the standard WordPress comments widget) display basic comments by default, which are recorded in wp_comments with a blank comment_type. If NextGEN uses a custom comment type, you would need to add a code snippet to modify the options passed to the get_comments function in the plugin.

    If you let me know about the comment type and I can send you the code snippet if required.

    Thanks,
    Andy

    Thread Starter pheisholt

    (@pheisholt)

    Hi

    Thanks for the response.

    Unfortunately, the comment_type doesn’t seem to be the problem here. The comment_type field is blank for absolutely all comments, including the NextGEN comments.

    I can send you credentials to a test site, if you’re interested in taking a look at it yourself.

    -paul-

    Hi Paul,

    That’s strange. I would have thought they would come back from the database if the comment type is blank. As the comments don’t appear in the default WordPress ‘Recent Comments’ widget either, it could be that NextGEN is filtering them out somewhere. Perhaps you could reach out to NextGEN support to see if they can shed any light on it.

    Andy

    Thread Starter pheisholt

    (@pheisholt)

    Hi

    I will do that. I’ve already been in touch with them several times about this, but I haven’t had them explain how they store their comments. So I will give it a try.

    However, it would be helpful if you could provide the SQL query which is triggered by the BRC widget. I assume that it joins several tables, since the wp_commnents table alone does not differentiate between regular comments and the NextGEN comments.

    -paul-

    Hi there,

    We use the core function get_comments() to retrieve the comments, so the SQL gets built by WordPress in WP_Comment_Query. I did a bit of digging in core and this is the SQL which WordPress is using when the Better Recent Comments widget loads:

    SELECT  wp_comments.comment_ID FROM wp_comments JOIN wp_posts ON wp_posts.ID = wp_comments.comment_post_ID 
    WHERE ( comment_approved = '1' ) AND wp_posts.post_status IN ('publish')  
    ORDER BY wp_comments.comment_date_gmt DESC LIMIT 0,5
    
    • This reply was modified 4 years, 8 months ago by Andy Keith.
    • This reply was modified 4 years, 8 months ago by Andy Keith.
    Thread Starter pheisholt

    (@pheisholt)

    Hi

    Thanks – that brings us one step closer.

    This SQL picks out the 5 most recent comments based on comment_date_gmt. And in my case it lists 5 comment IDs – two of which are NextGEN image comments.

    As you probably already have guessed, I don’t know the inner workings of WordPress, but this SQL only seems to fetch the comment IDs. So I’m assuming that these IDs are passed on to another function in order to actually display the comments in the widget.

    Do you know which function that is, and if so which SQL query it triggers? My guess is that that SQL query may explain why the NextGEN comments are ignored – although they are present in the ID list from the get_comments() function.

    -paul-

    Hi,

    In WP_Comment_Query->get_comments(), after it fetches the comment IDs, it then primes the cache for those IDs, and uses the result to build the full comments which are returned to the widget. This is the SQL in _prime_comment_caches:

    
    sprintf( "SELECT $wpdb->comments.* FROM $wpdb->comments WHERE comment_ID IN (%s)", join( ',', array_map( 'intval', $non_cached_ids ) ) );
    

    Hope that helps.

Viewing 15 replies - 1 through 15 (of 36 total)
  • The topic ‘Include NextGEN photo comments in BRC widget’ is closed to new replies.