• stephendent

    (@stephendent)


    I am having trouble getting comments to work properly on a theme I am developing. As of right now everything appears properly except for the comment threads themselves.

    For example, I have a post that currently has 3 comments on it. The theme recognizes them and shows the comment count, it shows the comment box and if you submit something wordpress recognizes it… just nothing ever shows up on the page itself.

    Here is the code I am using:

    function.php

    <?php
    /* Create a function for register_nav_menus() */
    function add_wp3menu_support() {
        register_nav_menus(
            array(
            'main-menu' => __('Main Navigation'),
            'another-menu' => __('Another Navigation')
                )
         );
    }
    // Initialise the menus with the theme.
    add_action('init', add_wp3menu_support);
    
    if ( function_exists('register_sidebar') )
    register_sidebar(array(
    'before_widget' => '<div class="sidebar">',
    'after_widget' => '</div>',
    'before_title' => '<h2>',
    'after_title' => '</h2>',
    ));
    
    function pagination($pages = '', $range = 4)
    {
         $showitems = ($range * 2)+1; 
    
         global $paged;
         if(empty($paged)) $paged = 1;
    
         if($pages == '')
         {
             global $wp_query;
             $pages = $wp_query->max_num_pages;
             if(!$pages)
             {
                 $pages = 1;
             }
         }  
    
         if(1 != $pages)
         {
             echo "<div class=\"pagination\"><span>Page ".$paged." of ".$pages."</span>";
             if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo "<a href='".get_pagenum_link(1)."'>&laquo; First</a>";
             if($paged > 1 && $showitems < $pages) echo "<a href='".get_pagenum_link($paged - 1)."'>&lsaquo; Previous</a>";
    
             for ($i=1; $i <= $pages; $i++)
             {
                 if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems ))
                 {
                     echo ($paged == $i)? "<span class=\"current\">".$i."</span>":"<a href='".get_pagenum_link($i)."' class=\"inactive\">".$i."</a>";
                 }
             }
    
             if ($paged < $pages && $showitems < $pages) echo "<a href=\"".get_pagenum_link($paged + 1)."\">Next &rsaquo;</a>";
             if ($paged < $pages-1 &&  $paged+$range-1 < $pages && $showitems < $pages) echo "<a href='".get_pagenum_link($pages)."'>Last &raquo;</a>";
             echo "</div>\n";
         }
    }
    function custom_breadcrumbs(){
        $delimiter = '&raquo;';
        $name = 'Home';
        $currentBefore = '<span class="current">';
        $currentAfter = '</span>';
    
        if(!is_home() && !is_front_page() || is_paged()){
    
            global $post;
            $home = get_bloginfo('url');
            echo '<a href="' . $home . '">' . $name . '</a> ' . $delimiter . ' ';
    
            if(is_tax()){
                  $term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
                  echo $currentBefore . $term->name . $currentAfter;
    
            } elseif (is_category()){
                global $wp_query;
                $cat_obj = $wp_query->get_queried_object();
                $thisCat = $cat_obj->term_id;
                $thisCat = get_category($thisCat);
                $parentCat = get_category($thisCat->parent);
                if($thisCat->parent != 0) echo(get_category_parents($parentCat, TRUE, ' ' . $delimiter . ' '));
                echo $currentBefore . '';
                single_cat_title();
                echo '' . $currentAfter;
    
            } elseif (is_day()){
                echo '<a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a> ' . $delimiter . ' ';
                echo '<a href="' . get_month_link(get_the_time('Y'),get_the_time('m')) . '">' . get_the_time('F') . '</a> ' . $delimiter . ' ';
                echo $currentBefore . get_the_time('d') . $currentAfter;
    
            } elseif (is_month()){
                echo '<a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a> ' . $delimiter . ' ';
                echo $currentBefore . get_the_time('F') . $currentAfter;
    
            } elseif (is_year()){
                echo $currentBefore . get_the_time('Y') . $currentAfter;
    
            } elseif (is_single()){
                $postType = get_post_type();
                if($postType == 'post'){
                    $cat = get_the_category(); $cat = $cat[0];
                    echo get_category_parents($cat, TRUE, ' ' . $delimiter . ' ');
                } elseif($postType == 'portfolio'){
                    $terms = get_the_term_list($post->ID, 'portfolio-category', '', '###', '');
                    $terms = explode('###', $terms);
                    echo $terms[0]. ' ' . $delimiter . ' ';
                }
                echo $currentBefore;
                the_title();
                echo $currentAfter;
    
            } elseif (is_page() && !$post->post_parent){
                echo $currentBefore;
                the_title();
                echo $currentAfter;
    
            } elseif (is_page() && $post->post_parent){
                $parent_id  = $post->post_parent;
                $breadcrumbs = array();
                while($parent_id){
                    $page = get_page($parent_id);
                    $breadcrumbs[] = '<a href="' . get_permalink($page->ID) . '">' . get_the_title($page->ID) . '</a>';
                    $parent_id  = $page->post_parent;
                }
                $breadcrumbs = array_reverse($breadcrumbs);
                foreach ($breadcrumbs as $crumb) echo $crumb . ' ' . $delimiter . ' ';
                echo $currentBefore;
                the_title();
                echo $currentAfter;
    
            } elseif (is_search()){
                echo $currentBefore . __('Search Results for:', 'wpinsite'). ' &quot;' . get_search_query() . '&quot;' . $currentAfter;
    
            } elseif (is_tag()){
                echo $currentBefore . __('Post Tagged with:', 'wpinsite'). ' &quot;';
                single_tag_title();
                echo '&quot;' . $currentAfter;
    
            } elseif (is_author()) {
                global $author;
                $userdata = get_userdata($author);
                echo $currentBefore . __('Author Archive', 'wpinsite') . $currentAfter;
    
            } elseif (is_404()){
                echo $currentBefore . __('Page Not Found', 'wpinsite') . $currentAfter;
    
            }
    
            if(get_query_var('paged')){
            if(is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() ) echo ' (';
            echo ' ' . $delimiter . ' ' . __('Page') . ' ' . get_query_var('paged');
            if(is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() ) echo ')';
            }
    
        }
    }
    	add_theme_support( 'automatic-feed-links' );
    
    		add_theme_support( 'custom-background', array(
    		'default-color' => '353535',
    	) );
    
    	add_theme_support( 'custom-header', $custom_header_support );
    
    	if ( ! isset( $content_width ) )
    	$content_width = 960;
    
    /**
     * Pagination for archive, taxonomy, category, tag and search results pages
     *
     * @global $wp_query http://codex.wordpress.org/Class_Reference/WP_Query
     * @return Prints the HTML for the pagination if a template is $paged
     */
    function base_pagination() {
    	global $wp_query;
    
    	$big = 999999999; // This needs to be an unlikely integer
    
    	// For more options and info view the docs for paginate_links()
    	// http://codex.wordpress.org/Function_Reference/paginate_links
    	$paginate_links = paginate_links( array(
    		'base' => str_replace( $big, '%#%', get_pagenum_link($big) ),
    		'current' => max( 1, get_query_var('paged') ),
    		'total' => $wp_query->max_num_pages,
    		'mid_size' => 5
    	) );
    
    	// Display the pagination if more than one page is found
    	if ( $paginate_links ) {
    		echo '<div class="pagination">';
    		echo $paginate_links;
    		echo '</div><!--// end .pagination -->';
    	}
    }
    ?>

    comments.php

    <?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 twentytwelve_comment() which is
     * located in the functions.php file.
     *
     * @package WordPress
     * @subpackage Twenty_Twelve
     * @since Twenty Twelve 1.0
     */
    
    /*
     * If the current post is protected by a password and
     * the visitor has not yet entered the password we will
     * return early without loading the comments.
     */
    if ( post_password_required() )
    	return;
    ?>
    
    <div id="comments" class="comments-area">
    
    	<?php // You can start editing here -- including this comment! ?>
    
    	<?php if ( have_comments() ) : ?>
    		<h2 class="comments-title">
    			<?php
    				printf( _n( 'One thought on &ldquo;%2$s&rdquo;', '%1$s thoughts on &ldquo;%2$s&rdquo;', get_comments_number(), 'twentytwelve' ),
    					number_format_i18n( get_comments_number() ), '<span>' . get_the_title() . '</span>' );
    			?>
    		</h2>
    
    		<ol class="commentlist">
    			<?php wp_list_comments( array( 'callback' => 'twentytwelve_comment', 'style' => 'ol' ) ); ?>
    		</ol><!-- .commentlist -->
    
    		<?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : // are there comments to navigate through ?>
    		<nav id="comment-nav-below" class="navigation" role="navigation">
    			<h1 class="assistive-text section-heading"><?php _e( 'Comment navigation', 'twentytwelve' ); ?></h1>
    			<div class="nav-previous"><?php previous_comments_link( __( '&larr; Older Comments', 'twentytwelve' ) ); ?></div>
    			<div class="nav-next"><?php next_comments_link( __( 'Newer Comments &rarr;', 'twentytwelve' ) ); ?></div>
    		</nav>
    		<?php endif; // check for comment navigation ?>
    
    		<?php
    		/* If there are no comments and comments are closed, let's leave a note.
    		 * But we only want the note on posts and pages that had comments in the first place.
    		 */
    		if ( ! comments_open() && get_comments_number() ) : ?>
    		<p class="nocomments"><?php _e( 'Comments are closed.' , 'twentytwelve' ); ?></p>
    		<?php endif; ?>
    
    	<?php endif; // have_comments() ?>
    
    	<?php comment_form(); ?>
    
    </div><!-- #comments .comments-area -->

    single.php

    <?php get_header(); ?>
    
    <div class="container">
    <div class="bread"><?php custom_breadcrumbs(); ?></div>
    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>
    <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
        <div class="article">
    
    <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">
    <?php the_title(); ?></a></h2>
    <div class="info">Date: <strong><?php the_time('F jS, Y') ?></strong> | Author: <strong><?php the_author(); ?></strong> | Category: <strong><?php the_category(' '); ?></strong></div>
    <?php the_content() ?>
    		<?php wp_link_pages( array( 'before' => '<div class="page-link"><span>' . __( 'Pages:', 'twentyeleven' ) . '</span>', 'after' => '</div>' ) ); ?>
    <div class="tags"><strong><?php the_tags('<strong>Summary:</strong> ',' • ','<br />'); ?></strong></div>
    
    				<?php comments_template( '', true ); ?>
    
    </div><!-- end .article -->
        <?php endwhile; ?>
        <?php else : ?>
        <div align="center">
          <h2>No Posts to Display...</h2></div><?php endif; ?>
    <!-- start pagination -->
    <?php if ( function_exists('base_pagination') ) { base_pagination(); } else if ( is_paged() ) { ?>
    <div class="navigation clearfix">
    	<div class="alignleft"><?php next_posts_link('&laquo; Previous Entries') ?></div>
    	<div class="alignright"><?php previous_posts_link('Next Entries &raquo;') ?></div>
    </div>
    <?php } ?>
    
    </div><!-- end .container -->
    <div class="sidebarContainer">
    <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) : ?>
    
    <?php endif; ?>
    </div>
    <br clear="all" />
    <?php get_footer(); ?>

Viewing 5 replies - 1 through 5 (of 5 total)
  • The callback used in wp_list_comments() is still refering to twentytwelve_comment so you got to have that in your functions.php.

    janmanz

    (@janmanz)

    My problem would appear to be the same/very similar as the one described above, however as a complete novice to the world of WordPress I have no idea what to do about it.

    Any chance you can offer a solution that a novice could implement?

    I am using ‘modernise’ theme. I have successfully created a Guest Book page. The comments are left successfully and come in for approval, they get approved and appear at the bottom of the Guest Book page – when viewing it from the Dashboard, but the comments do not appear on the actual live web page. I am not savvy enough to figure out what to do, although I have randomly tried all sorts. Your help would be very much appreciated.

    Michael

    (@alchymyth)

    @janmanz

    please start your own topic;

    http://codex.wordpress.org/Forum_Welcome#Where_To_Post

    as you seem to be working with a commercial theme, please contact the theme’s developer for support.

    Thread Starter stephendent

    (@stephendent)

    Thank you that worked!

    Thread Starter stephendent

    (@stephendent)

    I actually just realized although the comments now function properly my menu has broke. Any idea why?

    Please let me know if I can provide further information.

    Thanks

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Comment threads not visible’ is closed to new replies.