Comment form won't show on my wp blog posts - php

I have a wordpress site with a customized theme, and I have included comments into my single.php file, which looks like this:
<?php get_header();?>
<div id="content">
<div class="right">
<div class="article">
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<h1><?php the_permalink() ?>"><?php the_title(); ?></a></h1>
<small><?php the_time('F jS, Y'); ?></small>
<?php the_content();?>
<br /><br />
<hr />
<br /><br />
<?php comments_template(); ?>
<?php endwhile; else: ?>
<p>Sorry, no posts matched your criteria.</p>
<?php endif; ?>
</div></div>
<?php get_sidebar(); ?>
</div>
<?php get_footer();?>
Still, the comment form won't show up underneath my blog posts. I have enabled comments in the back end.

I don't Know your template code it is correct or no but your code contain error because you used error position to put comment template code
put the comment template code outside the loop and within the container class
like this
<?php get_header();?>
<div id="content">
<div class="right">
<div class="article">
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<h1><?php the_permalink() ?>"><?php the_title(); ?></a></h1>
<small><?php the_time('F jS, Y'); ?></small>
<?php the_content();?>
<br /><br />
<hr />
<br /><br />
<?php endwhile; else: ?>
<p>Sorry, no posts matched your criteria.</p>
<?php endif; ?>
</div>
<?php comments_template(); ?>
</div>
<?php get_sidebar(); ?>
</div>
<?php get_footer();?>
My code
this code within comments.php file
<?php
/* Prevent the direct loading of comments.php */
if (!empty($_SERVER['SCRIPT-FILENAME']) && basename($_SERVER['SCRIPT- FILENAME']) == 'comments.php') {
die(__('You can not access this file directly.', 'Yallanpe-Theme'));
}
/* If the post is password protected then display text and return */
if(post_password_required()) : ?>
<h5>
<?php
_e('This Post is password protected, Enter the password to view the comments', 'Yallanpe-Theme');
return;
?>
</h5>
<?php endif;
/* If we have comments to display, we display them */
if(have_comments()) : ?>
<div id="comments-container">
<?php wp_list_comments( array('walker' => new YPE_walker_comment)); ?>
<script>
$(document).ready(function() {
$("#comments-container ul#comment-list li.depth-1 .comment-avatar img").addClass("img-thumbnail");
$("#comments-container ul#comment-list li.depth-1 ul.children .comment-avatar img").addClass("img-circle");
});
</script>
</div><!-- /#comments-container -->
<?php if (get_comment_pages_count() > 1 && get_option('page_comments')) : ?>
<div class="comments-nav-section">
<h5 class="text-left"><?php previous_comments_link(__('← Older Comments', 'Yallanpe-Theme')); ?></h5>
<h5 class="text-right"><?php next_comments_link(__('Newer Comments →', 'Yallanpe-Theme')); ?></h5>
</div><!-- end comment-nav-section -->
<?php endif; ?>
<?php
/* If we don't have comments and the comments are closed, display a text */
elseif (!comments_open() && !is_page() && post_type_supports(get_post_type(), 'comments')) : ?>
<h5> <?php _e('Comments are Closed.', 'Yallanpe-Theme'); ?> </h5>
<?php endif;
/* Display the comment form */
comment_form();
?>
and this code below within functions.php (I used Bootstarp framework for comment form)
<?php
class YPE_walker_comment extends Walker_Comment {
var $tree_type = 'comment';
var $db_fields = array( 'parent' => 'comment_parent', 'id' => 'comment_ID' );
function __construct() { ?>
<h4>Comments</h4>
<ul id="comment-list">
<?php }
function start_lvl( &$output, $depth = 0, $args = array() ) {
$GLOBALS['comment_depth'] = $depth + 1; ?>
<ul class="children">
<?php }
function end_lvl( &$output, $depth = 0, $args = array()) {
$GLOBALS['comment_depth'] = $depth + 1; ?>
</ul>
<?php }
function start_el( &$output, $comment, $depth, $args, $id = 0 ) {
$depth++;
$GLOBALS['comment_depth'] = $depth;
$GLOBALS['comment'] = $comment;
$parent_class = (empty($args['has_children']) ? '' : 'parent'); ?>
<li <?php comment_class($parent_class); ?> id="comment-<?php comment_ID() ?>">
<div class="row">
<div class="col-sm-2">
<div class="comment-avatar">
<?php
$avatar_size = 80;
if ($comment->comment_parent != 0) { $avatar_size = 80; }
echo get_avatar($comment, $avatar_size);
?>
</div>
</div>
<div class="col-sm-10">
<div class="comment-header">
<?php
$reply_args = array(
'add_below' => $add_below,
'depth' => $depth,
'max_depth' => $args['max_depth']
);
?>
<ul id='author-time' class="list-inline">
<li><?php echo get_comment_author_link(); ?> </li>
<li class="pull-right text-muted"><?php comment_date(); ?> at <?php comment_time(); ?></li>
</ul>
<em>
<ul id="reply-delete" class="list-inline">
<li><?php comment_reply_link(array_merge($args, $reply_args)); ?></li>
<?php if (current_user_can('edit_post')) { $id = get_comment_ID(); ?>
<li><?php echo ' Edit'; ?></li>
<li><?php echo ' Delete'; ?></li>
<li><?php echo ' Spam'; ?></li>
<?php } ?>
</ul>
</em>
</div>
<div class="comment-content">
<?php
if( !$comment->comment_approved ) : ?>
<em class="text-muted">
<?php _e('Your comment is awaiting moderation.', 'Yallanpe Theme'); ?>
</em>
<?php else: comment_text(); ?>
<?php endif; ?>
</div>
</div>
</div>
<?php }
function end_el( &$output, $comment, $depth = 0, $args = array() ) { ?>
</li>
<?php }
function __destruct() { ?>
</ul>
<?php }
}
function YPE_custom_comment_form($defaults) {
$comment_notes_after = '';
$defaults ['comment_notice_before'] = '';
$defaults ['comment_notes_after'] = $comment_notes_after;
$defaults ['id_form'] = 'commentform';
$defaults ['comment_field'] = '<p class="form-group">
<div class="form-group">
<div class="input-group">
<span class="input-group-addon"> <span class="glyphicon glyphicon-comment"></span></span>
<textarea class="form- control" name="comment" id="comment" cols="30" rows="10">
</textarea>
</div>
</div>
</p>';
$defaults ['label_submit'] = 'Submit Comment';
$defaults ['title_reply'] = '<section id="comment-form"><h4>Add Comment</h4></section>';
return $defaults;
}
add_filter ('comment_form_defaults', 'YPE_custom_comment_form');
function YPE_custom_comment_fields() {
$commenter = wp_get_current_commenter();
$req = get_option('require_name_email');
$aria_req = ($req ? " aria-required='true'" : '');
$fields = array(
'author' => '<div class="form-group">' .
'<p>'.
'<div class="form-group">
<div class="input-group">
<span class="input-group-addon"><span class="glyphicon glyphicon-user"></span></span>' .
'<input type="text" class="form-control" id="author" name="author" value="'. esc_attr($commenter['comment_author']) .'" '. $aria_req .' placeholder="Enter Your Name" />'.
'</div>'.
'</div>'.
'</p>'.
'</div>',
'email' => '<div class="form-group">' .
'<p>'.
'<div class="form-group">
<div class="input-group">
<span class="input-group-addon"><span class="glyphicon glyphicon-envelope"></span></span>' .
'<input type="text" class="form-control" id="email" name="email" value="'. esc_attr($commenter['comment_author_email']) .'" '. $aria_req .' placeholder="Enter Your Email" />'.
'</div>'.
'</div>'.
'</p>'.
'</div>',
'url' => '<div class="form-group">' .
'<p>'.
'<div class="form-group">
<div class="input-group">
<span class="input-group-addon"><span class="glyphicon glyphicon-globe"></span></span>' .
'<input type="text" class="form-control" id="url" name="url" value="'.esc_attr($commenter['comment_author_url']) .'" placeholder="Enter Your Website URL" />'.
'</div>'.
'</div>'.
'</p>'.
'</div>',
);
return $fields;
}
add_filter ('comment_form_default_fields', 'YPE_custom_comment_fields');
?>

Related

How to get posts from a sidebar to display as a regular posts page

Ok so I have a sidebar widget that pulls in from a list of posts from a custom post type, which itself pulls in from all other custom post types. I need to display the list of posts from tab 2 in this sidebar on a page as a list of posts like an archive. This is the code that pulls in the posts for the sidebar:
<?php
// Prevent loading this file directly
defined( 'ABSPATH' ) || exit;
class ChemTabs extends WP_Widget {
function __construct() {
parent::__construct(
'tabs', _('Tabs Widget'),
array(
'description' => _('A tabs widget.'),
));
}
private function ce_getPostClass($style, $index) {
switch ($style) {
case 'first-up':
if ( $index == 0 ) return 'first-up';
else return 'list-type';
break;
default:
return $style;
}
}
private function ce_has($listStyle, $index, $post) {
$class = $this->ce_getPostClass($listStyle, $index);
$has = array(
'thumb' => false,
'terms' => true,
'date' => true,
'content' => false,
'excerpt' => false,
'title' => true,
'video' => false,
'webinarDate' => false
);
switch ($class) {
case 'first-up':
$has['thumb'] = true;
$has['excerpt'] = true;
break;
case 'list-type':
$has['terms'] = false;
break;
case 'thumblist':
$has['thumb'] = true;
break;
case 'single': // no need for this anymore probably
$has['content'] = true;
break;
}
switch ($post->post_type) {
case 'video':
$has['video'] = true;
break;
case 'webinar':
$has['webinarDate'] = true;
break;
}
return $has;
}
public function widget( $args, $instance ) {
global $post;
$instance['tab_1_title'] = isset($instance['tab_1_title'])?$instance['tab_1_title']:'Tab 1';
$instance['tab_2_title'] = isset($instance['tab_2_title'])?$instance['tab_2_title']:'Tab 2';
$instance['storylist_id_1'] = isset($instance['storylist_id_1']) ? $instance['storylist_id_1'] : '';
$instance['storylist_id_2'] = isset($instance['storylist_id_2']) ? $instance['storylist_id_2'] : '';
$instance['n'] = isset($instance['n']) ? $instance['n'] : 4;
$title = isset($instance['title'])?$instance['title']:'';
$type = isset($instance['type'])?$instance['type']:'color';
$class = isset($instance['class'])?$instance['class']:'brand-primary';
// Post list configuration
// Note: posts temporarily rendered with ajax
$list_style = isset($instance['listStyle'])?$instance['listStyle']:'thumblist';
$list_post_type = isset($instance['post_type'])?$instance['post_type']:'post';
$list_filter = isset($instance['filter'])?$instance['filter']:'{}';
$list_display = isset($instance['display'])?$instance['display']:5;
$list_channel = isset($instance['channel'])?$instance['channel']:0;
$list_division = isset($instance['division'])?$instance['division']:0;
$readmore = isset($instance['readmore'])?$instance['readmore'] : '';
$list_args1 = array( "post_type" => "any", "post__in" => get_post_meta($instance['storylist_id_1'], 'storylist', true), "orderby" => "post__in" );
$posts1 = new WP_Query();
$posts1 = $posts1->query($list_args1);
$list_args2 = array( "post_type" => "any", "post__in" => get_post_meta($instance['storylist_id_2'], 'storylist', true), "orderby" => "post__in" );
$posts2 = new WP_Query();
$posts2 = $posts2->query($list_args2);
// Note: posts temporarily rendered with ajax
echo $args['before_widget'];
$instance['tab_2_title'] = get_the_title($instance['storylist_id_2']);
//#TODO: Use get_template_part('content/post', $modifier); on tabs too.
?>
<div class="module tabs">
<div class="striped striped-gray">
<!-- Nav tabs -->
<ul class="nav nav-tabs nav-justified" role="tablist">
<li class="active">
<a href="#tab-pane-1" role="tab" data-toggle="tab">
<h2 class="h4"><?= $instance['tab_1_title'] ?></h2>
</a>
</li>
<li>
<a href="#tab-pane-2" role="tab" data-toggle="tab">
<h2 class="h4"><?= $instance['tab_2_title'] ?></h2>
</a>
</li>
</ul>
<!-- Tab panes -->
<div class="tab-content">
<div class="tab-pane active" id="tab-pane-1">
<div class="post-list no-c-paginator" max="<?= $instance['n'] ?>">
<?php
$n = 0;
foreach((array)$posts1 as $post): setup_postdata($post);
$n++;
if ( $n % 3 == 1) {
?> <div class="no-c-container<?php echo $n == 1 ? ' active' : '';?>"> <?php
}
?>
<article class="article thumblist no-c-paginator-item">
<!-- thumbnail -->
<?php echo the_post_thumbnail('cm_thumb', array('class' => 'img-thumbnail pull-left', 'style' => 'margin-right: 0.5em;')) ?>
<header>
<!-- terms -->
<?php if (!empty($terms) ): ?>
<p class="terms">
<?= $terms[0]['name'] ?>
</p>
<?php endif; ?>
<!-- title -->
<h3 class="title"><?php echo apply_filters('the_title', the_title()); ?></h3>
<!-- Time -->
<div class="date-author">
<?php include(locate_template('UI/byline.php')); ?>
<span class="topic"><?php echo cm_get_single_topic() ?></span>
</div>
</header>
<div class="clearfix"></div><!-- to clear the thumbnail's left floating -->
</article>
<?php
if ( $n % 3 == 0) {
?> </div> <?php
}
endforeach; wp_reset_postdata();
if ( $n % 3 != 0) {
?> </div> <?php
}
?>
<?php if($readmore): ?>
<div class="actions">
<button href="<?php echo $readmore; ?>" class="btn btn-primary btn-xs">View More</button>
</div>
<?php endif; ?>
</div>
<div class="actions">
<button class="btn btn-primary prev-item" disabled="disabled"><i class="fa fa-chevron-circle-left"></i> Prev</button>
<button class="btn btn-primary next-item">Next <i class="fa fa-chevron-circle-right"></i></button>
</div>
</div>
<div class="tab-pane" id="tab-pane-2">
<div class="post-list no-c-paginator" max="<?= $instance['n'] ?>">
<?php
$n = 0;
foreach((array)$posts2 as $post):
$n++;
if ( $n % 3 == 1) {
?> <div class="no-c-container<?php echo $n == 1 ? ' active' : '';?> "> <?php
}
?>
<article class="article thumblist no-c-paginator-item">
<!-- thumbnail -->
<?php echo get_the_post_thumbnail($post->ID, 'cm_thumb', array('class' => 'img-thumbnail pull-left', 'style' => 'margin-right: 0.5em;')) ?>
<header>
<!-- terms -->
<?php if (!empty($terms) ): ?>
<p class="terms">
<?= $terms[0]['name'] ?>
</p>
<?php endif; ?>
<!-- title -->
<h3 class="title"><?php echo apply_filters('the_title', $post->post_title); ?></h3>
<!-- Time -->
<div class="date-author">
<time datetime="<?php the_time('c'); ?>" pubdate="pubdate" ><?php the_time('F j, Y'); ?></time>
<?php include(locate_template('UI/byline.php')); ?>
<span class="topic"><?php echo cm_get_single_topic() ?></span>
</div>
</header>
<div class="clearfix"></div><!-- to clear the thumbnail's left floating -->
</article>
<?php
if ( $n % 3 == 0) {
?> </div> <?php
}
endforeach;
if ( $n % 3 != 0) {
?> </div> <?php
}
?>
<?php //if($readmore): ?>
<div class="actions">
View More
</div>
<?php //endif; ?>
<!--<div class="actions">
<button class="btn btn-primary prev-item" disabled="disabled"><i class="fa fa-chevron-circle-left"></i> Prev</button>
<button class="btn btn-primary next-item">Next <i class="fa fa-chevron-circle-right"></i></button>
</div>-->
</div>
</div>
</div>
</div>
</div>
<?php
echo $args['after_widget'];
}
public function form( $instance ) {
$instance['tab_1_title'] = isset($instance['tab_1_title'])?$instance['tab_1_title']:'Tab 1';
$instance['tab_2_title'] = isset($instance['tab_2_title'])?$instance['tab_2_title']:'Tab 2';
$instance['n'] = isset($instance['n'])?$instance['n']:4;
$sl_posts = get_posts(array(
'posts_per_page' => -1,
'post_type' => 'storylist'
));
?>
<h5>Tab 1</h5>
<p>
<label for="<?php echo $this->get_field_id( 'tab_1_title' ); ?>"><?php _e( 'Title:' ); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id( 'tab_1_title' ); ?>" name="<?php echo $this->get_field_name( 'tab_1_title' ); ?>" type="text" value="<?php echo esc_attr( $instance['tab_1_title'] ); ?>">
</p>
<p>
<label for="<?php echo $this->get_field_id( 'storylist_id_1' ); ?>"><?php _e( 'Story List:' ); ?></label>
<select id="<?php echo $this->get_field_id( 'storylist_id_1' ); ?>" name="<?php echo $this->get_field_name( 'storylist_id_1' ); ?>">
<?php
if (count($sl_posts)) {
foreach($sl_posts as $storyList) {
$selected = ($instance['storylist_id_1'] == $storyList->ID ? "selected='selected'" : "");
echo "<option value='{$storyList->ID}' {$selected}>{$storyList->post_title}</option>";
}
} else {
echo "<option value='0'>"._('No Story Lists Found')."</option>";
}
?>
</select>
</p>
<!-- Number of items to show -->
<p>
<label for="<?php echo $this->get_field_id( 'n' ); ?>"><?php _e( 'Number of items to show at once:' ); ?></label>
<input id="<?php echo $this->get_field_id( 'n' ); ?>" name="<?php echo $this->get_field_name( 'n' ); ?>" type="number" min="0" step="1" value="<?php echo intval($instance['n']) ?>">
</p>
<h5>Tab 2</h5>
<p>
<label for="<?php echo $this->get_field_id( 'tab_2_title' ); ?>"><?php _e( 'Title:' ); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id( 'tab_2_title' ); ?>" name="<?php echo $this->get_field_name( 'tab_2_title' ); ?>" type="text" value="<?php echo esc_attr( $instance['tab_2_title'] ); ?>">
</p>
<p>
<label for="<?php echo $this->get_field_id( 'storylist_id_2' ); ?>"><?php _e( 'Story List:' ); ?></label>
<select id="<?php echo $this->get_field_id( 'storylist_id_2' ); ?>" name="<?php echo $this->get_field_name( 'storylist_id_2' ); ?>">
<?php
if (count($sl_posts)) {
foreach($sl_posts as $storyList) {
$selected = ($instance['storylist_id_2'] == $storyList->ID ? "selected='selected'" : "");
echo "<option value='{$storyList->ID}' {$selected}>{$storyList->post_title}</option>";
}
} else {
echo "<option value='0'>"._('No Story Lists Found')."</option>";
}
?>
</select>
</p>
<?php
}
public function update( $new_instance, $old_instance ) {
$instance = array();
$instance['tab_1_title'] = isset($new_instance['tab_1_title'])?$new_instance['tab_1_title']:'Tab 1';
$instance['tab_2_title'] = isset($new_instance['tab_2_title'])?$new_instance['tab_2_title']:'Tab 2';
$instance['storylist_id_1'] = isset($new_instance['storylist_id_1']) ? (int)$new_instance['storylist_id_1'] : 0;
$instance['storylist_id_2'] = isset($new_instance['storylist_id_2']) ? (int)$new_instance['storylist_id_2'] : 0;
$instance['n'] = isset($new_instance['n']) ? (int)$new_instance['n'] : 4;
return $instance;
}
}
add_action( 'widgets_init', function(){ register_widget( 'ChemTabs' ); });
I created a page template specifically for this page, but it just comes up blank. Here is the code for that page:
<?php
/*
Template Name: Custom StoryList Archives
*/
?>
<?php get_header(); ?>
<?php
if ( is_single(210639) ) {
$args = array( 'post_type' => 'storylist', 'posts_per_page' => 30 );
}
endif();
?>
<?php get_footer(); ?>
What am I missing????
I solved this by adding this code: $list_args2 = array( "post_type" => "any", "post__in" => get_post_meta( 210639, 'storylist', true), "orderby" => "post__in", 'post_status' => 'publish' );

How do I get the posts from single page custom post type from a sidebar to display in a page?

I have a custom post type called storylist, which is done as a plugin for a sidebar widget.The custom post type story list compiles lists of other custom post types and displays them in the sidebar. The same way the posts are displaying in the sidebar, I need to have that same list, which in this case is "hot topics" display on a page when the "view more" button is clicked. The best I got was an archive of all the storylist posts but when you click on them, such as hot topics, it take you to the url http://site/storylist/hot-topics , which is the correct url, but it's blank and only shows the title of the page. Any suggestions on how to make those posts appear on hot topics?
Here's the code to make it display in the widget:
<?php
// Prevent loading this file directly
defined( 'ABSPATH' ) || exit;
class ChemTabs extends WP_Widget {
function __construct() {
parent::__construct(
'tabs', _('Tabs Widget'),
array(
'description' => _('A tabs widget.'),
));
}
private function ce_getPostClass($style, $index) {
switch ($style) {
case 'first-up':
if ( $index == 0 ) return 'first-up';
else return 'list-type';
break;
default:
return $style;
}
}
private function ce_has($listStyle, $index, $post) {
$class = $this->ce_getPostClass($listStyle, $index);
$has = array(
'thumb' => false,
'terms' => true,
'date' => true,
'content' => false,
'excerpt' => false,
'title' => true,
'video' => false,
'webinarDate' => false
);
switch ($class) {
case 'first-up':
$has['thumb'] = true;
$has['excerpt'] = true;
break;
case 'list-type':
$has['terms'] = false;
break;
case 'thumblist':
$has['thumb'] = true;
break;
case 'single': // no need for this anymore probably
$has['content'] = true;
break;
}
switch ($post->post_type) {
case 'video':
$has['video'] = true;
break;
case 'webinar':
$has['webinarDate'] = true;
break;
}
return $has;
}
public function widget( $args, $instance ) {
global $post;
$instance['tab_1_title'] = isset($instance['tab_1_title'])?$instance['tab_1_title']:'Tab 1';
$instance['tab_2_title'] = isset($instance['tab_2_title'])?$instance['tab_2_title']:'Tab 2';
$instance['storylist_id_1'] = isset($instance['storylist_id_1']) ? $instance['storylist_id_1'] : '';
$instance['storylist_id_2'] = isset($instance['storylist_id_2']) ? $instance['storylist_id_2'] : '';
$instance['n'] = isset($instance['n']) ? $instance['n'] : 4;
$title = isset($instance['title'])?$instance['title']:'';
$type = isset($instance['type'])?$instance['type']:'color';
$class = isset($instance['class'])?$instance['class']:'brand-primary';
// Post list configuration
// Note: posts temporarily rendered with ajax
$list_style = isset($instance['listStyle'])?$instance['listStyle']:'thumblist';
$list_post_type = isset($instance['post_type'])?$instance['post_type']:'post';
$list_filter = isset($instance['filter'])?$instance['filter']:'{}';
$list_display = isset($instance['display'])?$instance['display']:5;
$list_channel = isset($instance['channel'])?$instance['channel']:0;
$list_division = isset($instance['division'])?$instance['division']:0;
$readmore = isset($instance['readmore'])?$instance['readmore'] : '';
$list_args1 = array( "post_type" => "any", "post__in" => get_post_meta($instance['storylist_id_1'], 'storylist', true), "orderby" => "post__in" );
$posts1 = new WP_Query();
$posts1 = $posts1->query($list_args1);
$list_args2 = array( "post_type" => "any", "post__in" => get_post_meta($instance['storylist_id_2'], 'storylist', true), "orderby" => "post__in" );
$posts2 = new WP_Query();
$posts2 = $posts2->query($list_args2);
// Note: posts temporarily rendered with ajax
echo $args['before_widget'];
$instance['tab_2_title'] = get_the_title($instance['storylist_id_2']);
//#TODO: Use get_template_part('content/post', $modifier); on tabs too.
?>
<div class="module tabs">
<div class="striped striped-gray">
<!-- Nav tabs -->
<ul class="nav nav-tabs nav-justified" role="tablist">
<li class="active">
<a href="#tab-pane-1" role="tab" data-toggle="tab">
<h2 class="h4"><?= $instance['tab_1_title'] ?></h2>
</a>
</li>
<li>
<a href="#tab-pane-2" role="tab" data-toggle="tab">
<h2 class="h4"><?= $instance['tab_2_title'] ?></h2>
</a>
</li>
</ul>
<!-- Tab panes -->
<div class="tab-content">
<div class="tab-pane active" id="tab-pane-1">
<div class="post-list no-c-paginator" max="<?= $instance['n'] ?>">
<?php
$n = 0;
foreach((array)$posts1 as $post): setup_postdata($post);
$n++;
if ( $n % 3 == 1) {
?> <div class="no-c-container<?php echo $n == 1 ? ' active' : '';?>"> <?php
}
?>
<article class="article thumblist no-c-paginator-item">
<!-- thumbnail -->
<?php echo the_post_thumbnail('cm_thumb', array('class' => 'img-thumbnail pull-left', 'style' => 'margin-right: 0.5em;')) ?>
<header>
<!-- terms -->
<?php if (!empty($terms) ): ?>
<p class="terms">
<?= $terms[0]['name'] ?>
</p>
<?php endif; ?>
<!-- title -->
<h3 class="title"><?php echo apply_filters('the_title', the_title()); ?></h3>
<!-- Time -->
<div class="date-author">
<?php include(locate_template('UI/byline.php')); ?>
<span class="topic"><?php echo cm_get_single_topic() ?></span>
</div>
</header>
<div class="clearfix"></div><!-- to clear the thumbnail's left floating -->
</article>
<?php
if ( $n % 3 == 0) {
?> </div> <?php
}
endforeach; wp_reset_postdata();
if ( $n % 3 != 0) {
?> </div> <?php
}
?>
<?php if($readmore): ?>
<div class="actions">
<button href="<?php echo $readmore; ?>" class="btn btn-primary btn-xs">View More</button>
</div>
<?php endif; ?>
</div>
<div class="actions">
<button class="btn btn-primary prev-item" disabled="disabled"><i class="fa fa-chevron-circle-left"></i> Prev</button>
<button class="btn btn-primary next-item">Next <i class="fa fa-chevron-circle-right"></i></button>
</div>
</div>
<div class="tab-pane" id="tab-pane-2">
<div class="post-list no-c-paginator" max="<?= $instance['n'] ?>">
<?php
$n = 0;
foreach((array)$posts2 as $post):
$n++;
if ( $n % 3 == 1) {
?> <div class="no-c-container<?php echo $n == 1 ? ' active' : '';?> "> <?php
}
?>
<article class="article thumblist no-c-paginator-item">
<!-- thumbnail -->
<?php echo get_the_post_thumbnail($post->ID, 'cm_thumb', array('class' => 'img-thumbnail pull-left', 'style' => 'margin-right: 0.5em;')) ?>
<header>
<!-- terms -->
<?php if (!empty($terms) ): ?>
<p class="terms">
<?= $terms[0]['name'] ?>
</p>
<?php endif; ?>
<!-- title -->
<h3 class="title"><?php echo apply_filters('the_title', $post->post_title); ?></h3>
<!-- Time -->
<div class="date-author">
<time datetime="<?php the_time('c'); ?>" pubdate="pubdate" ><?php the_time('F j, Y'); ?></time>
<?php include(locate_template('UI/byline.php')); ?>
<span class="topic"><?php echo cm_get_single_topic() ?></span>
</div>
</header>
<div class="clearfix"></div><!-- to clear the thumbnail's left floating -->
</article>
<?php
if ( $n % 3 == 0) {
?> </div> <?php
}
endforeach;
if ( $n % 3 != 0) {
?> </div> <?php
}
?>
<?php //if($readmore): ?>
<div class="actions">
View More
</div>
<?php //endif; ?>
<!--<div class="actions">
<button class="btn btn-primary prev-item" disabled="disabled"><i class="fa fa-chevron-circle-left"></i> Prev</button>
<button class="btn btn-primary next-item">Next <i class="fa fa-chevron-circle-right"></i></button>
</div>-->
</div>
</div>
</div>
</div>
</div>
<?php
echo $args['after_widget'];
}
public function form( $instance ) {
$instance['tab_1_title'] = isset($instance['tab_1_title'])?$instance['tab_1_title']:'Tab 1';
$instance['tab_2_title'] = isset($instance['tab_2_title'])?$instance['tab_2_title']:'Tab 2';
$instance['n'] = isset($instance['n'])?$instance['n']:4;
$sl_posts = get_posts(array(
'posts_per_page' => -1,
'post_type' => 'storylist'
));
?>
<h5>Tab 1</h5>
<p>
<label for="<?php echo $this->get_field_id( 'tab_1_title' ); ?>"><?php _e( 'Title:' ); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id( 'tab_1_title' ); ?>" name="<?php echo $this->get_field_name( 'tab_1_title' ); ?>" type="text" value="<?php echo esc_attr( $instance['tab_1_title'] ); ?>">
</p>
<p>
<label for="<?php echo $this->get_field_id( 'storylist_id_1' ); ?>"><?php _e( 'Story List:' ); ?></label>
<select id="<?php echo $this->get_field_id( 'storylist_id_1' ); ?>" name="<?php echo $this->get_field_name( 'storylist_id_1' ); ?>">
<?php
if (count($sl_posts)) {
foreach($sl_posts as $storyList) {
$selected = ($instance['storylist_id_1'] == $storyList->ID ? "selected='selected'" : "");
echo "<option value='{$storyList->ID}' {$selected}>{$storyList->post_title}</option>";
}
} else {
echo "<option value='0'>"._('No Story Lists Found')."</option>";
}
?>
</select>
</p>
<!-- Number of items to show -->
<p>
<label for="<?php echo $this->get_field_id( 'n' ); ?>"><?php _e( 'Number of items to show at once:' ); ?></label>
<input id="<?php echo $this->get_field_id( 'n' ); ?>" name="<?php echo $this->get_field_name( 'n' ); ?>" type="number" min="0" step="1" value="<?php echo intval($instance['n']) ?>">
</p>
<h5>Tab 2</h5>
<p>
<label for="<?php echo $this->get_field_id( 'tab_2_title' ); ?>"><?php _e( 'Title:' ); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id( 'tab_2_title' ); ?>" name="<?php echo $this->get_field_name( 'tab_2_title' ); ?>" type="text" value="<?php echo esc_attr( $instance['tab_2_title'] ); ?>">
</p>
<p>
<label for="<?php echo $this->get_field_id( 'storylist_id_2' ); ?>"><?php _e( 'Story List:' ); ?></label>
<select id="<?php echo $this->get_field_id( 'storylist_id_2' ); ?>" name="<?php echo $this->get_field_name( 'storylist_id_2' ); ?>">
<?php
if (count($sl_posts)) {
foreach($sl_posts as $storyList) {
$selected = ($instance['storylist_id_2'] == $storyList->ID ? "selected='selected'" : "");
echo "<option value='{$storyList->ID}' {$selected}>{$storyList->post_title}</option>";
}
} else {
echo "<option value='0'>"._('No Story Lists Found')."</option>";
}
?>
</select>
</p>
<?php
}
public function update( $new_instance, $old_instance ) {
$instance = array();
$instance['tab_1_title'] = isset($new_instance['tab_1_title'])?$new_instance['tab_1_title']:'Tab 1';
$instance['tab_2_title'] = isset($new_instance['tab_2_title'])?$new_instance['tab_2_title']:'Tab 2';
$instance['storylist_id_1'] = isset($new_instance['storylist_id_1']) ? (int)$new_instance['storylist_id_1'] : 0;
$instance['storylist_id_2'] = isset($new_instance['storylist_id_2']) ? (int)$new_instance['storylist_id_2'] : 0;
$instance['n'] = isset($new_instance['n']) ? (int)$new_instance['n'] : 4;
return $instance;
}
}
add_action( 'widgets_init', function(){ register_widget( 'ChemTabs' ); });
Is there any way I can make a page template displaying the page id? I tried to do that but it didn't display anything.
I solved this by adding this code $list_args2 = array( "post_type" => "any", "post__in" => get_post_meta( 210639, 'storylist', true), "orderby" => "post__in", 'post_status' => 'publish' );

Page template suddenly not displaying the_content()

I've suddenly had an issue with a site I run.
Yesterday, the Business Page template on my site stopped showing the_content() copy. I updated 4 plugins earlier in the day; Contact Form 7, Yoast SEO, Jetpack and Wordfence Security. I can't 100% link these as the reason for the issue, because I never noticed the missing content. It was reported by a user. However I know the content was displaying 2 days ago, for sure.
Either way, I individually deactivated all my plugins, but the content didn't reappear.
Below is the code for the page template:
<?php
get_header();
// Calculate the best link back
$taxonomy = reset(wp_get_post_terms( get_the_ID(), 'business' ));
$back_link = get_term_link( $taxonomy, 'business' );
?>
<?php $sidebar_class = ''; ?>
<?php if($background_image = ardee('business_header')) { ?>
<div class="business-header" style="background-image: url(<?php echo $background_image; ?>);">
<?php } else { ?>
<?php $sidebar_class .= ' business-sidebar-flush'; ?>
<div class="business-header business-header-missing">
<?php } ?>
<div class="container">
<div class="row">
< Back to Listings
</div>
</div>
</div>
<div class="container">
<div class="row business-wrapper">
<div class="business-main col-sm-7">
<h1 class="business-title"><?php the_title(); ?></h1>
<h5 class="business-subtitle"><?php echo ardee('business_address'); ?></h5>
<div class="business-content copy">
<?php the_content(); ?>
</div>
<?php if($gallery = ardee('business_gallery')) { ?>
<div class="box business-gallery">
<h4 class="box-title">Photos</h4>
<div class="modal-gallery business-gallery row">
<?php foreach($gallery as $image) { ?>
<div class="business-gallery-image col-sm-4">
<img src="<?php echo $image['sizes']['business-thumb']; ?>" class="img-responsive">
</div>
<?php } ?>
</div>
</div>
<?php } ?>
<?php if($facilities = ardee('facilities')) { ?>
<div class="box business-facilities">
<?php $facilities_title = ( ardee( 'facilities_title' ) ) ? ardee( 'facilities_title' ) : 'Facilities'; ?>
<h4 class="box-title"><?php echo $facilities_title; ?></h4>
<ul class="list-unstyled list-facilities copy">
<?php foreach($facilities as $facility) { ?>
<li><i class="fa fa-check"></i> <?php echo $facility['facility']; ?></li>
<?php } ?>
</ul>
</div>
<?php } ?>
<?php if( $documents = ardee('document_categories') ) { ?>
<?php foreach(ardee('document_categories') as $category) { ?>
<div class="box business-category">
<h4 class="box-title"><?php echo $category['title']; ?></h4>
<div class="business-files row">
<?php foreach($category['documents'] as $document) { ?>
<div class="business-gallery-image col-sm-4">
<span><?php echo $document['document_title']; ?>
</div>
<?php } ?>
</div>
</div>
<?php } ?>
<?php } ?>
</div>
<div class="business-aside col-sm-5">
<div class="business-sidebar <?php echo $sidebar_class; ?> box">
<?php if ( has_post_thumbnail() ) { ?>
<div class="business-logo-holder">
<?php the_post_thumbnail( 'business-logo', array( 'class' => 'business-logo img-responsive' ) ); ?>
</div>
<?php } ?>
<div class="business-information">
<?php if($meta = ardee('contact_number')) { ?>
<div class="business-details">
<i class="fa fa-phone t-blue"></i>
<strong><?php echo $meta; ?></strong>
</div>
<?php } ?>
<?php if($meta = ardee('business_address')) { ?>
<div class="business-details">
<i class="fa fa-home t-blue"></i>
<strong><?php echo $meta; ?></strong>
</div>
<?php } ?>
<?php if($meta = ardee('contact_email')) { ?>
<div class="business-details">
<i class="fa fa-envelope t-blue"></i>
<strong><?php echo encrypt_email($meta); ?></strong>
</div>
<?php } ?>
<?php if($meta = ardee('business_website')) { ?>
<div class="business-details">
<i class="fa fa-link t-blue"></i>
<strong><?php echo $meta; ?></strong>
</div>
<?php } ?>
<?php if($facebook = ardee('social_accounts', 'facebook_url') || $twitter = ardee('social_accounts', 'twitter_account')) { ?>
<div class="business-details business-social">
<strong>Social Profiles: </strong>
<?php if($facebook = ardee('social_accounts', 'facebook_url')) { ?><i class="fa fa-facebook-official"></i> <?php } ?>
<?php if($twitter = ardee('social_accounts', 'twitter_account')) { ?><i class="fa fa-twitter"></i><?php } ?>
</div>
<?php } ?>
</div>
<?php if($business_email = ardee('contact_email')) { ?>
<div class="business-contact">
<h4>Contact Business</h4>
<?php echo do_shortcode('[contact-form-7 id="4" title="Business Contact Form"]'); ?>
</div>
<?php } ?>
</div>
<?php $open_hours = reset( ardee( 'open_hours' ) ); ?>
<?php if( $open_hours['monday'] || $open_hours['tuesday'] || $open_hours['saturday'] || ardee( 'lunch_hours' ) ) { ?>
<div class="business-opening">
<h4>Opening Hours</h4>
<dl class="business-hours">
<?php if( $open_hours['monday'] || $open_hours['tuesday'] || $open_hours['saturday'] ) { ?>
<?php foreach($open_hours as $opening_day => $opening_hours) { ?>
<?php if($opening_hours) { ?>
<div class="business-timeslot <?php echo business_open_status($opening_day, $opening_hours); ?>">
<span class="pull-right"><?php echo $opening_hours; ?></span>
<?php echo ucwords($opening_day); ?>
</div>
<?php } ?>
<?php } ?>
<?php } ?>
<?php if( ardee( 'lunch_hours' ) ) { ?>
<?php foreach(ardee('lunch_hours') as $opening) { ?>
<?php if($opening_hours['time']) { ?>
<div class="business-timeslot t-red">
<span class="pull-right"><?php echo $opening['time']; ?></span>
<?php echo $opening['title']; ?>
</div>
<?php } ?>
<?php } ?>
<?php } ?>
</dl>
</div>
<?php } ?>
</div>
</div>
</div>
<?php get_footer(); ?>
Anyone spot any glaring issues? I should stress that I didn't edit this in any way prior to the issue.
The content appears fine on all other templates, it is only this one that has the issue, but it's a very important page.
You can view one of the affected pages directly here: http://goo.gl/8L0kNU
I think the issue is you used the_content(); without loop and without loop they can't get the content of page. Use below code and write your code in between them and then check.
<?php
while ( have_posts() ) : the_post();
// Write your code here
endwhile;
?>

Custom Image Gallery is not fetching the images on WordPress

I am using an Image Gallery in Custom Post Type on my WordPress Website. The Plugin I am using for that is Advanced Custom Fields. There is some error, due to which image gallery is not getting displayed on frontend.
Please check the page.
http://divinepower.co.in/cof/projects/residential/surrey-hills-vic/
Though the same code is working fine on another custom post type.
http://divinepower.co.in/cof/brands/gloster/asta/
The code I am using is
<?php get_header(); ?>
<div id="content">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php
// Show the Gallery
if( have_rows('gallery_slideshow') ):
echo '<div class="projects-gallery-wrap">';
echo '<div class="projects-gallery">';
// loop through the rows of data
while ( have_rows('gallery_slideshow') ) : the_row();
$imgObj = get_sub_field('image', $post->ID);
echo '<img class="item" src="'.$imgObj[sizes]['projects-gallery'].'" alt="'.$imgObj[alt].'"/>';
endwhile;
echo '</div>';
echo '</div>';
endif;
?>
<div id="inner-content" class="wrap cf">
<main id="main" class="main-content" role="main" itemscope itemprop="mainContentOfPage" itemtype="http://schema.org/Blog">
<div class="gallery-controls">
<button class="prev"><i class="fa fa-chevron-left"></i></button>
<button class="next"><i class="fa fa-chevron-right"></i></button>
</div>
<article id="post-<?php the_ID(); ?>" <?php post_class('cf'); ?> role="article" itemscope itemtype="http://schema.org/BlogPosting">
<?php
$currentBrandName = cosh_get_brand_name();
$currentBrandSlug = cosh_get_brand_slug();
?>
<div class="content">
<header class="article-header">
<div class="title-wrap">
<h1 class="entry-title single-title" itemprop="headline"><?php the_title(); ?></h1>
<?php
// Brand Image
print apply_filters( 'taxonomy-images-list-the-terms', '', array(
'before' => '<ul class="projects-logos">',
'after' => '</ul>',
'image_size' => 'full',
'taxonomy' => 'brand'
) );
?>
</div>
<?php
// Social share
$currentURL = get_permalink( $post->ID );
?>
<div class="social-share">
<i class="fa fa-facebook"></i>
<i class="fa fa-pinterest-p"></i>
</div>
</header>
<section class="entry-content cf" itemprop="articleBody">
<div class="content-wrap">
<?php the_content(); ?>
<?php
// projects Link
$projectsURL = site_url()."/brand/".$currentBrandSlug;
if($projects){ ?>
View all <?php echo $currentBrandName; ?> projectss ›
<?php }; ?>
</div>
<?php
// Additional Info
$materials = get_field('materials', $post->ID);
$projectsSpecs = get_field('projects_specs', $post->ID);
if($materials || $projectsSpecs){ ?>
<div class="additional-info">
<?php
// Materials
if($materials){ ?>
<h4>Materials <i class="fa fa-pencil"></i></h4>
<p><?php the_field('materials'); ?></p>
<?php };
// projects Specs
if($projectsSpecs){ ?>
Download Specs <i class="fa fa-download"></i>
<?php }; ?>
</div>
<?php } ?>
</section>
<?php/*
// Show the Gallery
if( have_rows('gallery_slideshow') ):
echo '<div class="projects-gallery-wrap-mobile">';
echo '<div class="projects-gallery-mobile">';
// loop through the rows of data
while ( have_rows('gallery_slideshow') ) : the_row();
$imgObj = get_sub_field('image', $post->ID);
echo '<img class="item" src="'.$imgObj[sizes]['projects-gallery'].'" alt="'.$imgObj[alt].'"/>';
endwhile;
echo '</div>';
echo '</div>';
endif;
*/ ?>
</div>
</article>
<?php get_template_part('parts/enquiry_form'); ?>
</main>
</div>
<?php endwhile; ?>
<?php endif; ?>
</div>
<?php get_footer(); ?>
Please help me to find the error. Thanks

Wordpress: Comments: Submitting a comment opens a related post

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.

Categories