WordPress.org

Ready to get started?Download WordPress

Forums

comments2 instead of <?php comments_template(); ?> (12 posts)

  1. jungledsales
    Member
    Posted 6 years ago #

    I have substituted <?php include (TEMPLATEPATH . '/comments2.php'); ?> for <?php comments_template(); ?> on my single-2 template but I lose all my comments. The form still shows up fine but no comments show up.

    I tried troubleshooting by mirroring comments.php and comments2.php to start with but I still have the same issue. I think it has something to do with the comment-template.php in the wp-include folder.

    Any suggestions how to get my comments2.php to show my comments?

  2. chaoskaizer
    Member
    Posted 6 years ago #

    try

    <?php comments_template(DIRECTORY_SEPARATOR.'comments2.php'); ?>
  3. richarduk
    Member
    Posted 6 years ago #

    I have an identical problem to jungledsales

    Chaoskaizer, your code produces a fatal error

    I didn't know that you could have different single.phps

    How's that done?

  4. richarduk
    Member
    Posted 6 years ago #

    Just found the answer to the second part, but the different comments.php templates still eludes me.

    The second part:

    http://wordpress.alanwho.com/different-single-post-pages-in-wordpress/

    <?php
    $post = $wp_query->post;
    if ( in_category('2') ) {
    include(TEMPLATEPATH . '/single-blog.php'); }
    elseif ( in_category('15') ) {
    include(TEMPLATEPATH . '/single-photography.php'); }
    elseif ( in_category('18') ) {
    include(TEMPLATEPATH . '/single-video.php'); }
    else {
    include(TEMPLATEPATH . '/single-default.php');
    }
    ?>
  5. chaoskaizer
    Member
    Posted 6 years ago #

    Chaoskaizer, your code produces a fatal error

    @richarduk: well its depend on who's asking?
    why dont u try the following richarduk

    <?php
    
    if (file_exists('TEMPLATEPATH.DIRECTORY_SEPARATOR.'comments2.php''){
      comments_template(DIRECTORY_SEPARATOR.'comments2.php');
    } else {
      trigger_error(__('stupids! I don\'t have that file yet'), E_USER_ERROR);
    }
    ?>
  6. richarduk
    Member
    Posted 6 years ago #

    :-)

    The error is this:

    Parse error: syntax error, unexpected T_STRING

    Even when I use this:

    <?php
    
    if (file_exists('TEMPLATEPATH.DIRECTORY_SEPARATOR.'comments2.php''){
      comments_template(DIRECTORY_SEPARATOR.'comments2.php');
    } else {
      trigger_error(__('Hmmm - I do have that file and it sill does not work'), E_USER_ERROR);
    }
    ?>
  7. Samuel Wood (Otto)
    Tech Ninja
    Posted 6 years ago #

    The first line is wrong.

    if (file_exists(TEMPLATEPATH.DIRECTORY_SEPARATOR.'comments2.php')){

    Use that instead.

  8. richarduk
    Member
    Posted 6 years ago #

    Still not working, though I've tried all sorts of permutations.

    <?php
    
    if (file_exists(TEMPLATEPATH.DIRECTORY_SEPARATOR.'comments2.php'){
      comments_template(DIRECTORY_SEPARATOR.'comments2.php');
    } else {
      trigger_error(__('Hmmm - I do have that file and it sill does not work'), E_USER_ERROR);
    }
    ?>

    Parse error: syntax error, unexpected '{'

  9. richarduk
    Member
    Posted 6 years ago #

    Chaoskaiser:

    Apologies, your first line of code does work.

    <?php comments_template(DIRECTORY_SEPARATOR.'comments2.php'); ?>

  10. chaoskaizer
    Member
    Posted 6 years ago #

    lol

  11. jungledsales
    Member
    Posted 6 years ago #

    chaoskaizer: Thanks. The first code suggestion worked.

    <?php comments_template(DIRECTORY_SEPARATOR.'comments2.php'); ?>

    richarduk: I used Ryan Boren's plugin at http://boren.nu/archives/2005/03/13/custom-post-templates-plugin/ to create multiple templates for single.phps

    It's especially nice since you can do each category individually like you do in your code above or you can have it display a unique template based on the post ID. Very cool stuff.

  12. richarduk
    Member
    Posted 6 years ago #

    jungledsales

    Thanks :-)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags