• As this seems completely non-obvious, can anyone tell me how to make the comments appear automatically on the homepage please?

    Before anyone accuses me of slackness, I’ve searched through the WordPress forums, documentation and various other web sites and haven’t found an answer yet. Come on…the truth is out there!

    Thanks,

    Neil

Viewing 7 replies - 1 through 7 (of 7 total)
  • I tell you, I have been around the moon and back again for months off and on doing the blog thing. I am looking for the same flipping answer!! It doesnt appear to be anywhere and yet alot of people have the comment box under there posts. I read that having the no comment link that goes into another page to view coments is a new thing.

    Thread Starter dodginess

    (@dodginess)

    Ok, I’m on a mission now! I’ll be back as soon as I find the answer and find it I will! Without having looked at any of the code yet, the normal URL to access the home page is

    http://www.mydomain.com/wordpress/

    but this is really

    http://www.mydomain.com/wordpress/index.php

    So…if the URL to access the first page of comments is

    http://www.mydomain.com/wordpress/?p=1#comments

    then this is really

    http://www.mydomain.com/wordpress/index.php?p=1#comments

    Or maybe it isn’t, because WordPress is obviously hiding whatever the name of the script is and so this might be a different script. Or maybe I just don’t really care any more!

    Thanks,

    Neil

    Thread Starter dodginess

    (@dodginess)

    No idea if this works or not (the demo site is down) but here’s a link to a plugin that supposedly does what we’re after:

    http://wordpress.org/extend/plugins/hide-or-show-comments/

    I’ll check this out later on and report back…

    Neil

    Thread Starter dodginess

    (@dodginess)

    That plugin doesn’t do what I want but what it does do is provide a link on any pages that already display comments to show/hide them dynamically (IE without reloading the page).

    I’ve just spending ages looking for a suitable plugin again without any luck so I’m going to try and figure out how to change the code. What I did find is that there must be two distinct scripts to load the homepage and to load whatever page (post?) is being displayed on the home page. As an example, to load the homepage I enter

    http://www.mydomain.com/wordpress/

    but if I want to view the page directly I can also use

    http://www.mydomain.com/wordpress/?p=1

    which is the same page but with all the comments expanded and without the menus.

    One file that’s worth looking at is

    /wp-includes/template-loader.php

    which looks at the URL to see what it’s supposed to be doing. If I mess about with this then I might be able to make it look at the page directly when it would normally display the home page design.

    More details to follow!

    Neil

    Thread Starter dodginess

    (@dodginess)

    Ok – I think I’m getting close to it now:

    Make a copy of the following file and then open it in your text editor:

    /wp-content/themes/default/index.php

    Find the section that looks like:

    <div id="content" class="narrowcolumn">
    
    <?php if (have_posts()) : ?>

    then replace it with:

    <div id="content" class="narrowcolumn">
    <?php query_posts('p=1&cpage=1'); ?>
    <?php if (have_posts()) : ?>

    Then find the section that looks like:

    <div class="entry">
    <?php the_content('Read the rest of this entry &raquo;'); ?>
    </div>

    then replace it with:

    <div class="entry">
    <?php the_content('Read the rest of this entry &raquo;'); ?>
    </div>
    <?php comments_template() ?>

    (The code above was taken from the comments.php file in the same folder.)

    This hack is a bit of a fudge because it messes up the sidebar code (some of the links don’t appear as normal) and it doesn’t have all the commenting controls. Plus, when you leave a comment it takes you to an ugly URL like:

    http://www.mydomain.com/wordpress/?p=1&cpage=1#comment-11

    which kind of gives the game away. Some kind of SEO-friendly plugin would make everything look a bit nicer.

    Not quite the comprehensive solution I wanted but it’s a start 🙂

    Neil

    Thread Starter dodginess

    (@dodginess)

    Ok – here’s a slighly better solution:

    Revert your modified index.php file to its original state (if you followed my instructions in the last message) then paste in the following line of code:

    <?php $withcomments = true; comments_template();?>

    What this does is display all of the comments for every post listed on the home page and to do this it should go somewhere sensible in “the loop”.

    If you just want to have only one post displayed on the homepage find the code that looks like:

    <div id="content" class="narrowcolumn">
    
    <?php if (have_posts()) : ?>

    and replace it with:

    <div id="content" class="narrowcolumn">
    query_posts('p=1');
    <?php if (have_posts()) : ?>

    The only problem with this is that the side bar looks broken again so there might be some kind of internal conflict going on or WordPress is getting confused about what sort of page it’s supposed to be showing. There’s probably another way to tell WordPress to only show one post so I’ll keep looking.

    Neil

    the sidebar looks broken because it reads the last query_post. To reset it, put this code after the loop, and before the sidebar.

    <?php query_posts($query_string); ?>

    Now using your code above, I can put comment directly under the post. However after I submit the comment form, it then loads directly to the post’s page. Is there a way to change the direction back to index.php?

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Setting comments to appear automatically on home page – how?’ is closed to new replies.