我正在尝试在自定义帖子上添加评论框 comments_template(); ,但不确定它为什么不会出现?请看下面的代码,让我知道我在做什么错误?
<?php
$temp = $wp_query; $wp_query= null;
$wp_query = new WP_Query(); $wp_query->query('showposts=1' . '&paged='.$paged);
while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
<h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
<div>
<?php if ( has_post_thumbnail() ) : ?>
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
<?php the_post_thumbnail(); ?>
</a>
<?php endif; ?>
</div>
<?php the_content(); ?>
<?php endwhile; ?>
<?php comments_template(); ?>
<?php if ($paged > 1) { ?>
<nav id="nav-posts">
<div class="prev"><?php next_posts_link('PREVIOUS POSTS'); ?></div>
<div class="next"><?php previous_posts_link('NEXT POSTS'); ?></div>
</nav>
<?php } else { ?>
<nav id="nav-posts">
<div class="prev"><?php next_posts_link('PREVIOUS POSTS'); ?></div>
</nav>
答案 0 :(得分:0)
注册自定义帖子类型如下:
$args = array(
'menu_icon' => 'dashicons-format-video',
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
//'rewrite' => array( 'slug' => 'book' ),
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => false,
'menu_position' => null,
'supports' => array('title', 'editor', 'comments')
);
register_post_type( 'custom_type', $args );