WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] View only comments per post. (11 posts)

  1. ssdesign
    Member
    Posted 8 years ago #

    Hi,
    I am developing a custom theme and heavily customising the feel of the blog.

    I am stuck at one place, when a user clicks the comments link, I want to display only comments (without the actual post content).

    If I am not wrong, the comments page uses the POST template file to render itself by adding:
    #comments
    to the link URL.

    Is it possible to create a custom template for comments page using this code?

    <?php comments_template(); ?>

    I am confused.....

    Any help?

  2. nearlythere
    Member
    Posted 8 years ago #

    you can find that included file called "comments.php" ... in your theme folder

    the default CSS is also loaded with custom classes for displaying comments.

    bon chance!

  3. ssdesign
    Member
    Posted 8 years ago #

    Yes that was the first thing i thought of.
    BUT
    When I look at the URL of comments on the index page, it says something like this:
    http://www.myWebsite.com/?p=82#comments

    Which means that by default, the comments link calls the INDEX.PHP file and adds:
    ?p=82#comments to it.

    If I were to call a custom comments page, what should the comment URL look like?

  4. moshu
    Member
    Posted 8 years ago #

    If exists WP uses the single.php template file to display a single post (aka "comment page") + the comments.php template is called in.
    If there is no single.php file ==> the index.php will be used.
    see Template_Hierarchy
    Based on this you can create a "single" template that won't show the content, just calls the comments.
    Warning: this is just an "educated guess" :) - but I'd give it a try.

  5. ssdesign
    Member
    Posted 8 years ago #

    Excellent,
    I solved it.

    Now my single.php looks like this:

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <?php comments_template(); ?>
    <?php endwhile; else: ?>
    <?php endif; ?>

    Thats it.
    Cool...

  6. moshu
    Member
    Posted 8 years ago #

    Glad it worked. Can you, please, mark this topic as "solved"?

  7. ssdesign
    Member
    Posted 8 years ago #

    oops... not solved yet :)

    I do get a comments page with just the comments
    BUT

    Now the post content is removed from the Archive pages as well... because it looks like comments and archive both use single.php

    Any idea how to tackle this one??

  8. ssdesign
    Member
    Posted 8 years ago #

    Sorry I mean POST PERMALINK and not ARCHIVE

  9. nearlythere
    Member
    Posted 8 years ago #

    ssdesign... hmmm... i think there's a conceptual block here.

    i see now that you thought the #comments was part of a URL query string telling the script to render comments. and that is why you were asking "what should the URL look like"

    in fact, a # indicates an "anchor". it's just a basic HTML tag to move 'within' a page, like halfway down, where the comments are. so in that sense it is not processed by PHP. see for example, how this page 'loads' to the middle:
    http://codex.wordpress.org/Blog_Design_and_Layout#Themes_and_Templates

    i hope that is clear...

    so now i am confused. i re-read all of your questions here. i guess i don't understand what you want in the end... you want a page of just all comments? there's a plugin for comments:

    have a look at some of these here:
    http://codex.wordpress.org/Plugins/Comments

  10. Valerie
    Member
    Posted 8 years ago #

    Is using the built in comments popup script and comments popup link tags an option for you? It would then keep the comments separate from your posts - once you change your single.php (permalink page which is usually used for showing comments) appropriately.

  11. ssdesign
    Member
    Posted 8 years ago #

    ok guys, sorry if I confused you all.

    I have recently shifted to WP and liked it so much that I went ahead and started developing a complete FLASH version of it.

    Now about this question, I tried what Valerie has already suggested, I modified the core include files and this is what I did:

    changes:
    echo $home . '/' . $wpcommentspopupfile.'?p='.$id.'#comments';

    to;
    echo $home . '/' . $wpcommentspopupfile.'?comments_popup='.$id;

    Then I modified the comments-popup.php in my theme folder to output a custom XML and there you go....

    Thanks again to everyone for flushing this out :)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags