• Resolved shortcircuit001

    (@shortcircuit001)


    Hello,
    Is there a way to automatically expand the comments below the post? The current display shows the number of comments for a particular post, however users need to navigate away from the page in order to view them.

    Thanks,
    Robert

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Eric Amundson

    (@sewmyheadon)

    Hi Robert,

    Is there a way to automatically expand the comments below the post?

    Are you wanting to add comments to each post on an archive or category page or are you referring to displaying the comments on a single post?

    Thread Starter shortcircuit001

    (@shortcircuit001)

    Hi Eric.
    Looking to display comments below the single post. Currently for a single post it shows the number of comments which is linked to the another page. I’m wanting to keep people on the same page if possible. Thanks

    Plugin Author Eric Amundson

    (@sewmyheadon)

    Howdy, @shortcircuit001 – sorry, I need to clarify.

    Currently for a single post it shows the number of comments which is linked to the another page.

    When I think of a single post, I think of the article by itself on the page; not as part of a list of posts, if that makes sense.

    So is that the case for you? It sounds like you’ve actually got a list of posts generated by Posts in Page and you’re hoping to show the comments for each directly underneath the post. Is that right?

    Thread Starter shortcircuit001

    (@shortcircuit001)

    Hey Eric, yeah I think you stated it correctly. So in my short code I got [ic_add_posts category=accounting] . The output shows Accounting and below “posted in Accounting | 2 Comments | Edit ”
    I would like to automatically expand those comments in the same cell if possible?

    Thanks

    Plugin Author Eric Amundson

    (@sewmyheadon)

    Howdy @shortcircuit001,

    Thanks for the added info.

    That’s totally not something I would have thought to do so I’ve not tried it so let me check on a few things and get back to you.

    Eric

    Thread Starter shortcircuit001

    (@shortcircuit001)

    Really appreciate it. I’ve been looking for a solution for this and your code gets the closest I’ve been able to find.

    Robert

    Plugin Author Eric Amundson

    (@sewmyheadon)

    Howdy @shortcircuit001,

    Here’s something you can try:

    1. Backup
    2. Copy the posts_loop_template.php file from the plugin’s /template/ folder into your theme’s root directory
    3. Open up the posts_loop_template.php you copied to your theme folder and look for the comments pop up section (currently line 66, I believe):

    <span class="comments-link">
    	<?php
    	comments_popup_link(
    		esc_html__( 'Leave a comment', 'posts-in-page' ),
    		esc_html__( '1 Comment', 'posts-in-page' ),
    		esc_html__( '% Comments', 'posts-in-page' )
    	);
    	?>
    </span>

    and replace with something like this:

    <span class="comments-link">
    	<?php
        global $withcomments;
    
    	// If comments are open or we have at least one comment, load up the comment template.
    	if ( comments_open() || get_comments_number($post->ID) ) {
    	    $withcomments = true;
    		comments_template();
    	}
    	
    	?>
    </span>

    This will be a bit theme-dependent so your mileage may vary. In testing with Twenty Nineteen, my only complaint is that I think it looks awkward having the comment forms as well as the comments. Of course, there’s no styling care to make it look better yet.

    When you put the template tag/function comments_template(); in a theme file, it calls a file called comments.php by default. In the case of this theme, that file contains the call to the form.

    I’m sure there are multiple ways to handle that but let’s see if how suggestion works for you.

    I hope that helps!

    Thread Starter shortcircuit001

    (@shortcircuit001)

    Eric I really appreciate the help! I tested it this morning and it actually works and looks great. Thanks for working with me on this!

    Plugin Author Eric Amundson

    (@sewmyheadon)

    Right on – glad to hear it. ??

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘automatically expanding comments’ is closed to new replies.