Forums

listing number of comments within Page content (8 posts)

  1. njg97r
    Member
    Posted 4 years ago #

    I have a Page with comments enabled using <?php comments_template(); ?> within the Loop of my Page template. And I'd like to display the number of comments on that page, within the Page content, similar to index.php listing the number of comments on posts with

    <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?>

    How would I accomplish this within the body of a Page?

  2. Kafkaesqui
    Moderator
    Posted 4 years ago #

  3. moshu
    Member
    Posted 4 years ago #

    Did you try to put the code above in your page template?

  4. njg97r
    Member
    Posted 4 years ago #

    The codex link says it must be in the Loop to function. I placed <p>This page currently has <?php comments_popup_link('no Comments »', '1 Comment »', '% Comments »'); ?></p> in the Page template, within the Loop, but nothing appears.

    I am seeking to place this line after the first paragraph of Page content... which can't be within the Loop, right?

    This is the page I'm testing: http://www.nathangibbs.com/self-portrait/

  5. moshu
    Member
    Posted 4 years ago #

    Use the template tag Kafkaesquí provided above.

  6. njg97r
    Member
    Posted 4 years ago #

    Oh, right... yes, that works within the Loop, thanks.

    But using the Loop, I'm limited to only the top or bottom of the page... How could I get it to display in the middle of the Page?

  7. Kafkaesqui
    Moderator
    Posted 4 years ago #

    You'd need a plugin that lets you run php from within post/Page content, such as:

    http://priyadi.net/archives/2005/03/02/wordpress-php-exec-plugin/
    http://www.nosq.com/2004/10/runphp-wordpress-plugin

  8. njg97r
    Member
    Posted 4 years ago #

    Thank you! You are my hero!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags