我在single.php中创建了一个简单的帖子页面。当我发布帖子时,会显示每个以前帖子链接的最新帖子。 :(无法理解这有什么不妥。
所有页面都重定向到同一页面。
我正在使用wp 3.9。
<?php get_header(); ?>
<div class = "right_sidebar" id = "main">
<div class = "inner">
<div class = "general_content clearboth">
<!--Post Format Standart begin-->
<div class = "main_content single ">
<?php
if (have_posts()) :
// Start the Loop.
while (have_posts()) : the_post();
?>
<?php $cats = get_the_category($id) ?>
<ul class = "breadcrumbs">
<li class = "home"><a href = "index.html">Home</a></li>
<li class = "all"><a href = "page-style1.html">All Posts</a></li>
<li class = "cat_post"><a href = "page-style1.html"><?php echo $cats[0]->cat_name; ?></a></li>
<li class = "current"><?php the_title(); ?></li>
</ul>
<h2 class = "page-title"><?php the_title(); ?></h2>
<div id = "post_content" class = "post_content" role = "main">
<article class = "type-post hentry">
<div class = "post-info">
<div class = "post_date">April 2, 2013</div>
<a href = "post-standart.html" class = "post_format">News</a> <a href = "post-standart.html" class = "comments_count">0</a>
<div class = "post_views">1045</div>
</div>
<!--<div class = "pic post_thumb"> <img src = "images/slider/image2.jpg" alt = "" > </div>-->
<div class = "post_content">
<?php the_content(); ?>
</div>
<div class = "block-social">
<div class = "soc_label">recommend to friends</div>
<ul id = "post_social_share" class = "post_social_share">
<li><a href = "http://www.facebook.com/share.php?u=#" class = "facebook_link"><img src = "<?php echo get_template_directory_uri() ?>/images/facebook-icon-big.png" class = "facebook_icon" alt = "facebook" ></a></li>
<li><a href = "https://twitter.com/share?text=#" class = "twitter_link"><img src = "<?php echo get_template_directory_uri() ?>/images/twitter-icon-big.png" class = "twitter_icon" alt = "twitter" ></a></li>
<li><a href = "https://plusone.google.com/_/+1/confirm?url=#" class = "gplus_link"><img src = "<?php echo get_template_directory_uri() ?>/images/gplus-icon-big.png" class = "gplus_icon" alt = "gplus" ></a></li>
<li><a href = "http://pinterest.com/pin/create/button/?url=#" class = "pinterest_link"><img src = "<?php echo get_template_directory_uri() ?>/images/pinterest-icon-big.png" class = "pinterest_icon" alt = "pinterest" ></a></li>
</ul>
</div>
</article>
<?php
endwhile;
endif;
?>
答案 0 :(得分:0)
你是从头开始制作页面还是有一个single.php而你刚刚编辑过它?因为如果你自己创建它,你应该查阅wordpress docs,你可能错过了一些重要的东西,比如加载帖子ID的类。
这就是Twenty Fourteen在single.php中要求发布帖子的方式。
<?php
// Start the Loop.
while ( have_posts() ) : the_post();
/*
* Include the post format-specific template for the content. If you want to
* use this in a child theme, then include a file called called content-___.php
* (where ___ is the post format) and that will be used instead.
*/
get_template_part( 'content', get_post_format() );
// Previous/next post navigation.
twentyfourteen_post_nav();
// If comments are open or we have at least one comment, load up the comment template.
if ( comments_open() || get_comments_number() ) {
comments_template();
}
endwhile;
?>