The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Other help with chris coyier’s wordpress comments hack

  • This topic is empty.
Viewing 1 post (of 1 total)
  • Author
  • #31317

    I’m trying to follow Chris’s hack about adding a custom message to the bottom of closed comments in wordpress. Here’s a link:

    custom message after comments

    I got the first part working ok to add a custom meta box in the wp admin panel however I’m having a hard time implementing the second part of the code. I can’t figure out how to add the code to comments.php

    First, do the comments need to be closed for this to work?

    Second, where and how should I add the code?

    Here’s the comments.php:

    * The template for displaying Comments.
    * The area of the page that contains both current comments
    * and the comment form. The actual display of comments is
    * handled by a callback to twentyten_comment which is
    * located in the functions.php file.
    * @package WordPress
    * @subpackage Twenty_Ten
    * @since Twenty Ten 1.0

    /* Stop the rest of comments.php from being processed,
    * but don't kill the script entirely -- we still have
    * to fully load the template.

    // You can start editing here -- including this comment!

    printf( _n( 'One Response to %2$s', '%1$s Responses to %2$s', get_comments_number(), 'twentyten' ),
    number_format_i18n( get_comments_number() ), '' . get_the_title() . '' );

    1 && get_option( 'page_comments' ) ) : // Are there comments to navigate through? ?>

      /* Loop through and list the comments. Tell wp_list_comments()
      * to use twentyten_comment() to format the comments.
      * If you want to overload this in a child theme then you can
      * define twentyten_comment() and that will be used instead.
      * See twentyten_comment() in twentyten/functions.php for more.
      wp_list_comments( array( 'callback' => 'twentyten_comment' ) );

    1 && get_option( 'page_comments' ) ) : // Are there comments to navigate through? ?>

    /* If there are no comments and comments are closed,
    * let's leave a little note, shall we?
    if ( ! comments_open() ) :

    Here’s Chris’s hack but I’m having a hard time understanding if have to break it up in certain parts and paste it in. Where do I add this:

    // regular outputting of comments stuff in here

    global $post;

    $custom_message = get_post_meta($post->ID, '_custom_comments_message', true);

    if ($custom_message != '') {

    echo '
    echo $custom_message;
    echo "

    } else {

    echo '
    Comments are closed. If you have something really important to add, contact us. Thank you!

    } ?>

    Thanks for your help….

Viewing 1 post (of 1 total)
  • The forum ‘Other’ is closed to new topics and replies.