I'm building a Wordpress theme of my own, and having a problem with my comment-page. I can post comments, but when I press the reply-button to reply to my own comment, I get a blank wp-comments-post.php - page when posting my reply. I've tried some solutions, but it's still not working. Any ideas?
This is my comments.php file :
<?php
/**
* The template for displaying Comments.
*
* The area of the page that contains comments and the comment form.
*
*/
/*
* 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 (!empty($_SERVER['SCRIPT_FILENAME']) && 'comments.php' == basename($_SERVER['SCRIPT_FILENAME']))
die('Please do not load this page directly. Thanks!');
if (post_password_required()) {
?>
<p class="nocomments">Det här inlägget är lösenordsskyddat. Knappa in lösenordet för att se inlägget.</p>
<?php
return;
}
?>
<div id="commentsbox" class="post">
<?php if (have_comments()) : ?>
<h3 id="comments">
<?php comments_number('Inga kommentarer',
'En kommentar',
'% kommentarer'); ?>
än så länge.</h3>
<ol class="commentlist">
<?php wp_list_comments(array(
'avatar_size' => 70)); ?>
</ol>
<div class="comment-nav">
<div class="alignleft">
<?php previous_comments_link() ?>
</div>
<div class="alignright">
<?php next_comments_link() ?>
</div>
</div>
<?php else : ?>
<?php if (comments_open()) : ?>
<?php else : ?>
<p class="nocomments">Kommentarer är avstängda</p>
<?php endif; ?>
<?php endif; ?>
<?php if (comments_open()) : ?>
<div class="commentform_wrapper">
<div class="post-info">
</div>
<div id="comment-form">
<?php $comment_args = array( 'title_reply'=>'Vänligen lämna dina synpunkter och kommentarer:',
'title_reply_to' => __( 'Svara %s' ),
'cancel_reply_link' => __( 'Stäng svar' ),
'label_submit'=>'Skicka',
'reply_text' => 'Svara',
'fields' => apply_filters( 'comment_form_default_fields', array(
'author' => '<p class="comment-form-author">' . '<label for="author">' . __( 'Namn' ) . '</label> ' . ( $req ? '<span>*</span>' : '' ) .
'<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . ' /></p>',
'email' => '<p class="comment-form-email">' .
'<label for="email">' . __( 'Mejl' ) . '</label> ' .
( $req ? '<span>*</span>' : '' ) .
'<input id="email" name="email" type="text" value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30"' . $aria_req . ' />'.'</p>',
'url' => '' ) ),
'comment_field' => '<p>' .
'<label for="comment">' . __( 'Kommentarer' ) . '</label>' .
'<textarea id="comment" name="comment" cols="45" rows="8" aria-required="true"></textarea>' .
'</p>',
'comment_notes_after' => '',
);
comment_form($comment_args); ?>
</div>
</div>
<?php endif; ?>
</div>
And this is my single.php file, in case you need it:
<?php
/**
* The Template for displaying all single posts.
*/
get_header('header3'); ?>
<section id="headerbox">
<header>
<h2 class="referensrubrik">Rubrik</h2>
</header>
<p class="referenstext">Text</p>
</section>
<?php
$post = $wp_query->post;
while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
<article id="blogpost2" id="post-<?php get_the_ID(); ?>" <?php post_class(); ?>>
<h2><?php the_title(); ?></h2>
<h5><?php the_time('F jS, Y') ?> <!-- by <?php the_author() ?> --></h5>
<?php the_content(); ?>
<hr>
</article>
<?php endwhile; ?>
<?php if ($paged > 1) { ?>
<nav id="nav-posts">
<div class="prev"><?php next_posts_link('« Äldre inlägg'); ?></div>
<div class="next"><?php previous_posts_link('Nyare inlägg »'); ?></div>
</nav>
<?php } else { ?>
<nav id="nav-posts">
<div class="prev"><?php next_posts_link('« Äldre inlägg'); ?></div>
</nav>
<?php } ?>
<?php wp_reset_postdata(); ?>
<!--Start Comment box-->
<?php comments_template(); ?>
<!--End Comment box-->
<?php get_footer(); ?>
Most of the time this is an (500) error:
Enable debugging (see https://codex.wordpress.org/Debugging_in_WordPress)
Open your develop bar in your browser
Record the requests
Check the http status code and error info
This typically only happens to me when I make a mistake with either leaving a line break or space in front of the pages opening PHP tag. While it does not looks not be the case based on the example code - but I would triple check that you have no carriage returns or spaces before the opening
Problem solved! Because I could comment and reply comments when logged in as admin, but not as an anonymous visitor, I cheched my discussion settings. They were set to send me an email every time someone posted a comment. Somehow this is failing and when I uncheched the box the problem was gone. I need to look up why the email is failing, but for now I'm just happy that everything is working as it should.
Some of this problem are from the server where you are hosted, you may me able to change it on the php settings,
post_max_size
, and the
upload_max_filesize
this will the solution of many problem uploading files on wordpress
Related
I am having some issues with my dynamic php sidebar and wanted to see if anyone finds any issues with my code. Right now, the aside and other sidebar classes are closing sooner than the end of the code. I was thinking there might be something else wrong with my code that I'm not aware of.
I have a php widget plugin installed, and the below code is written in the sidebar:
<div class="sidebar-container">
<button class="accordion" style="h5">Education</button>
<div class="accordion-content">
<p><?php echo '<span class="sidebar">' . get_field('education') . '</span>'; ?></p>
</div>
<?php if( get_field('licensescertifications') ) : ?><button class="accordion">Licenses/Certifications</button>
<div class="accordion-content">
<p><?php echo '<span class="sidebar">' . the_field('licensescertifications') . '</span>'; ?></p>
<?php endif; ?>
</div>
<?php if( get_field('honors') ) : ?><button class="accordion">Honors</button>
<div class="accordion-content">
<p><?php echo '<span class="sidebar">' . the_field('honors') . '</span>'; ?></p>
<?php endif; ?>
</div>
<?php if( get_field('publications') ) : ?><button class="accordion">Publications</button>
<div class="accordion-content">
<p><?php echo '<span class="sidebar">' . the_field('publications') . '</span>'; ?></p>
<?php endif; ?>
</div>
<?php if( get_field('affiliations') ) : ?><button class="accordion">Affiliations</button>
<div class="accordion-content">
<p><?php echo '<span class="sidebar">' . the_field('affiliations') . '</span>'; ?></p>
<?php endif; ?>
</div>
<?php if( get_field('languages') ) : ?><button class="accordion">Languages</button>
<div class="accordion-content">
<p><?php the_field('languages'); ?></p>
<?php endif; ?>
</div>
</div>
Maybe you should replace position of "endif" in each block? And replace "the_field" with "get_field" in "echo" line
<?php if( get_field('licensescertifications') ) : ?>
<button class="accordion">Licenses/Certifications</button>
<div class="accordion-content">
<p><?php echo '<span class="sidebar">' . get_field('licensescertifications') . '</span>'; ?></p>
</div>
<?php endif; ?>
Or shortly:
<?php if( $field_data = get_field('licensescertifications') ) : ?>
<button class="accordion">Licenses/Certifications</button>
<div class="accordion-content">
<p><?php echo '<span class="sidebar">' . $field_data . '</span>'; ?></p>
</div>
<?php endif; ?>
I have http://spainthephilippines.com/ where I use Rift Theme. Im having problem with showing the sidebar on single post page. On my index page the sidebar is showing, on the 404 page the sidebar is showing. It is working anywhere I use it just not in signle post page. I was looking 2 hours for answer but I cant find it. The theme is on version 1.0, so is it possible that to be the problem? Then why the sidebar shows on most pages? Anyone can help? Tell me if you need any code.
<?php global $theme; get_header(); ?>
<div id="main">
<?php $theme->hook('main_before'); ?>
<div id="content">
<?php $theme->hook('content_before'); ?>
<?php
if (have_posts()) : while (have_posts()) : the_post();
/**
* Find the post formatting for the single post (full post view) in the post-single.php file
*/
get_template_part('post', 'single');
endwhile;
else :
get_template_part('post', 'noresults');
endif;
?>
<?php $theme->hook('content_after'); ?>
</div><!-- #content -->
<?php get_sidebars(); ?>
<?php $theme->hook('main_after'); ?>
</div><!-- #main -->
EDIT
Here is the sidebar:
<?php global $theme; ?>
<div id="sidebar-primary">
<?php
if(!dynamic_sidebar('sidebar_primary')) {
/**
* The primary sidebar widget area. Manage the widgets from: wp-admin -> Appearance -> Widgets
*/
$theme->hook('sidebar_primary');
}
$theme->hook("sidebar_primary_after");
?>
And also the post-single.php:
<?php global $theme; ?>
<div <?php post_class('post post-single clearfix'); ?> id="post-<?php the_ID(); ?>">
<h2 class="title"><?php the_title(); ?></h2>
<div class="postmeta-primary">
<span class="meta_date"><?php echo get_the_date(); ?></span>
<span class="meta_categories"><?php the_category(', '); ?></span>
<?php if(comments_open( get_the_ID() )) {
?> <span class="meta_comments"><?php comments_popup_link( __( 'No comments', 'themater' ), __( '1 Comment', 'themater' ), __( '% Comments', 'themater' ) ); ?></span><?php
}
if(is_user_logged_in()) {
?> <span class="meta_edit"><?php edit_post_link(); ?></span><?php
} ?>
</div>
<div class="entry clearfix">
<?php
if(has_post_thumbnail()) {
the_post_thumbnail(
array($theme->get_option('featured_image_width_single'), $theme->get_option('featured_image_height_single')),
array("class" => $theme->get_option('featured_image_position_single') . " featured_image")
);
}
?>
<?php
the_content('');
wp_link_pages( array( 'before' => '<p><strong>' . __( 'Pages:', 'themater' ) . '</strong>', 'after' => '</p>' ) );
?>
<?php if(get_the_tags()) {
?><div class="postmeta-secondary"><span class="meta_tags"><?php the_tags('', ', ', ''); ?></span></div><?php
}
?>
<!-- Post ID <?php the_ID(); ?> wtf-->
<?php
if(comments_open( get_the_ID() )) {
comments_template('', true);
}
?>
I'm pretty new to Wordpress and I've been building a theme with reverie-master but the only problem is the search page. All the other pages, category, archive, etc are working.
I use this for searching in my header.php :
<form method="post" action="<?php echo home_url('/'); ?>" class="search-form" role="search">
<div class="small-9 columns no-pad">
<input type="text" class="search-input" name="s" placeholder="Search" value="" />
</div>
<div class="small-3 columns no-pad">
<input class="btn-submit postfix search-input" type="submit" value=""/>
</div>
This shows the search results on the homepage. If I type in "ok" in the search bar it takes me to example : www.homepage.com when it should be on www.homepage.com/?s=ok. The problem with it being on the home page, the paginations will take you to page 2 of the home blog feed instead on www.homepage.com/page/2/ when it should be something ilke this www.homepage.com/page/2/?s=test
When I manualy type in this url in the browser : www.homepage.com/page/2/?s=test the pagination is working. My problem is the pagination and I am wondering why the posts displays on the homepage(which I assume is the problem)
Here is my search.php code :
Starts with <?php get_header(); ?> and ends with <?php get_footer(); ?>
This is the loop in between with pagination :
<h2><?php _e('Search Results for', 'reverie'); ?> "<?php echo get_search_query(); ?>"</h2>
<?php if ( have_posts() ) : ?>
<?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<div class="row pad-row">
<div class="large-11 columns bor-bottom">
<a class="fade" href="<?php the_permalink(); ?>"><p class="feed-title"><?php the_title(); ?></p></a>
<p class="feed-info">By <span class="feed-author"><?php the_author(); ?> </span> <?php echo human_time_diff( get_the_time('U'), current_time('timestamp') ) . ' ago'; ?>
<?php
foreach((g_the_category()) as $category) {
if ($category->cat_name != 'featured') {
echo '<a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a> ';
}
}
?>
<span class="feed-cmt"><?php comments_number( '0 Comments', '1 Comments', '% Comments' ); ?>. </span></p>
<?php the_excerpt(); ?>
</div>
</div>
<?php endwhile; ?>
<?php else : ?>
<?php get_template_part( 'content', 'none' ); ?>
<?php endif; // end have_posts() check ?>
<!-- Start Pagination -->
<div class="row pad-row">
<div class="large-11 columns pagination-centered large-centered panel-page">
<?php /* Display navigation to next/previous pages when applicable */ ?>
<?php if ( function_exists('reverie_pagination') ) { reverie_pagination(); } else if ( is_paged() ) { ?>
<nav id="post-nav">
<div class="post-previous"><?php next_posts_link( __( '← Older posts', 'reverie' ) ); ?></div>
<div class="post-next"><?php previous_posts_link( __( 'Newer posts →', 'reverie' ) ); ?></div>
</nav>
<?php } ?>
</div>
</div>
Do not put search form directly. WP has a functionality to get search form called get_search_form(). This function prints wp basic search form, but still you can customize this. In order to customize, you can use a filter called get_search_form.
function custom_search_form( $form ) {
$form = '<form method="get" action="' . home_url('/') . '" class="search-form" role="search">
<div class="small-9 columns no-pad">
<input type="text" class="search-input" name="s" id="s" placeholder="Search" value="' . get_search_query() . '" />
</div>
<div class="small-3 columns no-pad">
<input class="btn-submit postfix search-input" id="searchsubmit" type="submit" value="'. esc_attr__( 'Search' ) .'"/>
</div>
</form>';
return $form;
}
add_filter( 'get_search_form', 'custom_search_form' );
And put this to functions.php
This is my first foray into customizing the WP comment form, and it's giving me a bit of trouble.
Ideally, I'd like to have a comment form with 3 fields: Name, Location, and Comment.
To facilitate that, I'm using arrays:
<?php comment_form(array(
'title_reply'=> 'Please feel free to share your home owning hopes and dreams.',
'fields' => apply_filters( 'comment_form_default_fields', $fields ),
'label_submit' => 'Share',
));
?>
In the comment list, I want the comment to display and just below that have "Name | Location"
<div class="comment-content"><?php comment_text(); ?><?php comment_author(); ?> | <?php echo $comment_author_url ?> </div>
As you can see on the live site, it isn't quite coming out that way. Any ideas why that may be? Tips and insight are appreciated.
functions.php
<?php
if ( ! function_exists( 'twentyeleven_comment' ) ) :
/**
* Template for comments and pingbacks.
*
* To override this walker in a child theme without modifying the comments template
* simply create your own twentyeleven_comment(), and that function will be used instead.
*
* Used as a callback by wp_list_comments() for displaying the comments.
*
* #since Twenty Eleven 1.0
*/
function twentyeleven_comment( $comment, $args, $depth ) {
$GLOBALS['comment'] = $comment;
switch ( $comment->comment_type ) :
case 'pingback' :
case 'trackback' :
?>
<li class="post pingback">
<p><?php _e( 'Pingback:', 'twentyeleven' ); ?> <?php comment_author_link(); ?><?php edit_comment_link( __( 'Edit', 'twentyeleven' ), '<span class="edit-link">', '</span>' ); ?></p>
<?php
break;
default :
?>
<li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
<article id="comment-<?php comment_ID(); ?>" class="comment">
<div class="comment-content"><?php comment_text(); ?><?php comment_author(); ?> | <?php echo $comment_author_url ?> </div>
</article><!-- #comment-## -->
<?php
break;
endswitch;
}
endif; // ends check for twentyeleven_comment()
// Custom callback to list comments in the your-theme style
function custom_comments($comment, $args, $depth) {
$GLOBALS['comment'] = $comment;
$GLOBALS['comment_depth'] = $depth;
?>
<li id="comment-<?php comment_ID() ?>" <?php comment_class() ?>>
<div class="comment-author vcard"><?php commenter_link() ?></div>
<div class="comment-meta"><?php printf(__('Posted %1$s at %2$s <span class="meta-sep">|</span> Permalink', 'your-theme'),
get_comment_date(),
get_comment_time(),
'#comment-' . get_comment_ID() );
edit_comment_link(__('Edit', 'your-theme'), ' <span class="meta-sep">|</span> <span class="edit-link">', '</span>'); ?></div>
<?php if ($comment->comment_approved == '0') _e("\t\t\t\t\t<span class='unapproved'>Your comment is awaiting moderation.</span>\n", 'your-theme') ?>
<div class="comment-content">
<?php comment_text() ?>
</div>
<?php // echo the comment reply link
if($args['type'] == 'all' || get_comment_type() == 'comment') :
comment_reply_link(array_merge($args, array(
'reply_text' => __('Reply','your-theme'),
'login_text' => __('Log in to reply.','your-theme'),
'depth' => $depth,
'before' => '<div class="comment-reply-link">',
'after' => '</div>'
)));
endif;
?>
<?php } // end custom_comments
// Custom callback to list pings
function custom_pings($comment, $args, $depth) {
$GLOBALS['comment'] = $comment;
?>
<li id="comment-<?php comment_ID() ?>" <?php comment_class() ?>>
<div class="comment-author"><?php printf(__('By %1$s on %2$s at %3$s', 'your-theme'),
get_comment_author_link(),
get_comment_date(),
get_comment_time() );
?></div>
<?php if ($comment->comment_approved == '0') _e('\t\t\t\t\t<span class="unapproved">Your trackback is awaiting moderation.</span>\n', 'your-theme') ?>
<div class="comment-content">
<?php comment_text() ?>
</div>
<?php } // end custom_pings
// Produces an avatar image with the hCard-compliant photo class
function commenter_link() {
$commenter = get_comment_author_link();
if ( ereg( '<a[^>]* class=[^>]+>', $commenter ) ) {
$commenter = ereg_replace( '(<a[^>]* class=[\'"]?)', '\\1url ' , $commenter );
} else {
$commenter = ereg_replace( '(<a )/', '\\1class="url "' , $commenter );
}
$avatar_email = get_comment_author_email();
$avatar = str_replace( "class='avatar", "class='photo avatar", get_avatar( $avatar_email, 80 ) );
echo $avatar . ' <span class="fn n">' . $commenter . '</span>';
} // end commenter_link
if (!function_exists('iweb_reverse_comments')) {
function iweb_reverse_comments($comments) {
return array_reverse($comments);
}
}
add_filter ('comments_array', 'iweb_reverse_comments');
// custom comment field
function my_fields($fields) {
$fields['Location'] = '';
return $fields;
}
add_filter('comment_form_default_fields','my_fields');
?>
share.php
<?php
/*
Template Name: Share
*/
?>
<?php get_header(); ?>
<div class="content-left">
<?php comments_template(); ?>
</div><!-- end content-left -->
<div class="content-right">
<?php wp_list_comments( array( 'callback' => 'twentyeleven_comment' )); ?></ul>
</div><!-- end content-right -->
<?php get_footer(); ?>
i don't think it's twentyeleven_comment that you have to edit.
try an echo in the twentyeleven_comment to see if it's the right function.
echo "twentyeleven_comment ";
exit;
i think twentyeleven_comment show all comments of a post in the post view not the post list.
I have a problem with my comments form.
Submitting a comment leads to open a related post.
Here's my comments.php:
<?php
if ( post_password_required() ) :
echo '<h3 class="comments-header">' . __('Password Protected', 'buddypress') . '</h3>';
echo '<p class="alert password-protected">' . __('Enter the password to view comments.', 'buddypress') . '</p>';
return;
endif;
if ( is_page() && !have_comments() && !comments_open() && !pings_open() )
return;
?>
<?php if ( have_comments() ) : ?>
<div id="comments">
<?php
// Only include comments
$numTrackBacks = 0; $numComments = 0;
foreach ( (array)$comments as $comment )
if ( 'comment' != get_comment_type() )
$numTrackBacks++;
else
$numComments++;
?>
<h3 id="comments">
<?php
printf( _n( '1 Kommentar', '%1$s Kommentare', $numComments, 'buddypress' ),
number_format_i18n( $numComments ), '<em>' . get_the_title() . '</em>' );
?>
</h3>
<?php do_action( 'bp_before_blog_comment_list' ) ?>
<ol class="commentlist">
<?php wp_list_comments() ; ?>
</ol><!-- .comment-list -->
<?php do_action( 'bp_after_blog_comment_list' ) ?>
<?php if ( get_option( 'page_comments' ) ) : ?>
<div class="comment-navigation paged-navigation">
<?php paginate_comments_links(); ?>
</div>
<?php endif; ?>
</div><!-- #comments -->
<?php else : ?>
<?php if ( pings_open() && !comments_open() && is_single() ) : ?>
<p class="comments-closed pings-open">
<?php printf( __('Comments are closed, but trackbacks and pingbacks are open.', 'buddypress'), trackback_url( '0' ) ); ?>
</p>
<?php elseif ( !comments_open() && is_single() ) : ?>
<p class="comments-closed">
<?php _e('Keine Kommentare erlaubt.', 'buddypress'); ?>
</p>
<?php endif; ?>
<?php endif; ?>
<?php if ( comments_open() ) : ?>
<div id="respond">
<div class="comment-avatar-box">
<div class="avb">
<?php if ( bp_loggedin_user_id() ) : ?>
<a href="<?php echo bp_loggedin_user_domain() ?>">
<?php echo get_avatar( bp_loggedin_user_id(), 50 ); ?>
</a>
<?php else : ?>
<?php echo get_avatar( 0, 50 ); ?>
<?php endif; ?>
</div>
</div>
<div class="comment-content">
<h3 id="reply" class="comments-header">
<?php comment_form_title( __( 'Leave a Reply', 'buddypress' ), __( 'Leave a Reply to %s', 'buddypress' ), true ); ?>
</h3>
<p id="cancel-comment-reply">
<?php cancel_comment_reply_link( __( 'Click here to cancel reply.', 'buddypress' ) ); ?>
</p>
<?php if ( get_option( 'comment_registration' ) && !$user_ID ) : ?>
<p class="alert">
<?php printf( __('You must be logged in to post a comment.', 'buddypress'), wp_login_url( get_permalink() ) ); ?>
</p>
<?php else : ?>
<?php do_action( 'bp_before_blog_comment_form' ) ?>
<form action="<?php echo site_url( 'wp-comments-post.php' ) ?>" method="post" id="commentform" class="standard-form">
<?php if ( $user_ID ) : ?>
<p class="log-in-out">
<?php printf( __('Logged in as %2$s.', 'buddypress'), bp_loggedin_user_domain(), $user_identity ); ?> <?php _e('Log out →', 'buddypress'); ?>
</p>
<?php else : ?>
<?php $req = get_option( 'require_name_email' ); ?>
<p class="form-author">
<label for="author"><?php _e('Name', 'buddypress'); ?> <?php if ( $req ) : ?><span class="required"><?php _e('*', 'buddypress'); ?></span><?php endif; ?></label>
<input type="text" class="text-input" name="author" id="author" value="<?php echo $comment_author; ?>" size="40" tabindex="1" />
</p>
<p class="form-email">
<label for="email"><?php _e('Email', 'buddypress'); ?> <?php if ( $req ) : ?><span class="required"><?php _e('*', 'buddypress'); ?></span><?php endif; ?></label>
<input type="text" class="text-input" name="email" id="email" value="<?php echo $comment_author_email; ?>" size="40" tabindex="2" />
</p>
<p class="form-url">
<label for="url"><?php _e('Website', 'buddypress'); ?></label>
<input type="text" class="text-input" name="url" id="url" value="<?php echo $comment_author_url; ?>" size="40" tabindex="3" />
</p>
<?php endif; ?>
<p class="form-textarea">
<label for="comment"><?php _e('Comment', 'buddypress'); ?></label>
<textarea name="comment" id="comment" cols="60" rows="10" tabindex="4"></textarea>
</p>
<?php do_action( 'bp_blog_comment_form' ) ?>
<p class="form-submit">
<input class="submit-comment button" name="submit" type="submit" id="submit" tabindex="5" value="<?php _e('Submit', 'buddypress'); ?>" />
<?php comment_id_fields(); ?>
</p>
<div class="comment-action">
<?php do_action( 'comment_form', $post->ID ); ?>
</div>
</form>
<?php do_action( 'bp_after_blog_comment_form' ) ?>
<?php endif; ?>
</div><!-- .comment-content -->
</div><!-- #respond -->
<?php endif; ?>
<?php if ( $numTrackBacks ) : ?>
<div id="trackbacks">
<span class="title"><?php the_title() ?></span>
<?php if ( 1 == $numTrackBacks ) : ?>
<h3><?php printf( __( '%d Trackback', 'buddypress' ), $numTrackBacks ) ?></h3>
<?php else : ?>
<h3><?php printf( __( '%d Trackbacks', 'buddypress' ), $numTrackBacks ) ?></h3>
<?php endif; ?>
<ul id="trackbacklist">
<?php foreach ( (array)$comments as $comment ) : ?>
<?php if ( get_comment_type() != 'comment' ) : ?>
<li><h5><?php comment_author_link() ?></h5><em>on <?php comment_date() ?></em></li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
</div>
<?php endif; ?>
An answer would be appreciated
Update:
My single.php:
<?php get_header(); ?>
<!-- LAESST DEN HEADER ERSCHEINEN -->
<div id="main">
<!-- DAS IST DER LOOP! HIER WIRD DER BEFEHL GEGEBEN, DEN INHALT ANZUZEIGEN (ARTIKEL ETC) -->
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<h2><?php the_title(); ?></h2> <!-- DIESER BEFEHL ZEIGT UND VERLINKT DIE ARTIKEL UEBERSCHRIFT -->
<div class="entry">
<?php the_content(); ?>
</div>
<?php endwhile; ?>
<div class="author-box">
<p><?php echo get_avatar( get_the_author_meta( 'user_email' ), '50' ); ?></p>
<p><?php printf( __( 'Geschrieben von %s', 'buddypress' ), bp_core_get_userlink( $post->post_author ) ) ?> am <?php the_time('j. F Y'); ?> um <?php the_time(); ?></p>
<p> Kategorie(n): <?php the_category(', '); ?> </p>
</div>
<div id="related-posts"
<?php
$tags = wp_get_post_tags($post->ID);
if ($tags) {
$tag_ids = array();
foreach($tags as $individual_tag) $tag_ids[] = $individual_tag->term_id;
$args=array(
'tag__in' => $tag_ids,
'post__not_in' => array($post->ID),
'showposts'=>3, // Number of related posts that will be shown.
'caller_get_posts'=>1
);
$my_query = new wp_query($args);
if( $my_query->have_posts() ) {
echo '<h3>Das könnte dich auch interessieren</h3><ul>';
while ($my_query->have_posts()) {
$my_query->the_post();
?>
<li><?php the_title(); ?></li>
<?php
}
echo '</ul>';
}
}
?>
</div>
<!--"NEXT POST" BZW "PREVIOUS POST" NAVIGATION -->
<p align="center"><?php next_posts_link('« Ältere Einträge') ?> <?php previous_posts_link('Neuere Einträge »') ?></p>
<?php endif; ?>
<?php comments_template(); ?> <!-- LAESST DAS KOMMENTARFELD ERSCHEINEN -->
</div><!-- main -->
<div id="sidebar">
<?php get_sidebar(); ?>
<!-- LAESST DIE SIDEBAR ERSCHEINEN -->
</div><!-- sidebar -->
<?php get_footer(); ?>
<!-- DIESER BEFEHL LAESST DEN FOOTER ERSCHEINEN -->
But why is it displayed incorrectly?
The only point in your code that could be responsible for your problem, as far as I can see, is at:
<div class="comment-action">
<?php do_action( 'comment_form', $post->ID ); ?>
</div>
$post->ID should hold the id of the current post or be null. If there is a problem with $post, it will be on the page that calls this comments template, single.php probably. You could try changing your current single.php file for the twentyten one and see if that solves the problem. Or post here that single.php file contents so we can check it.
EDIT:
On the single.php file, you have a new query being executed to get the related posts:
$args=array(
'tag__in' => $tag_ids,
'post__not_in' => array($post->ID),
'showposts'=>3, // Number of related posts that will be shown.
'caller_get_posts'=>1
);
$my_query = new wp_query($args);
if( $my_query->have_posts() ) {
This code is populating the $post variable with each of the related posts found, so once that code is done you will have the $post var holding the last post of the related posts retrieved with that query.
Easiest solution: cut the code for the related posts functionality (everything inside de "related-posts" div, including the opening and closing div tags) and paste it just before the </div><!-- main --> so it doesn't affect the comments or navigation parts.