我对Wordpress非常陌生。因此面对这个问题。在我的wordpress博客中,我不知道为什么page.php加载单个wordpress帖子而不是single.php。
page.php中包含以下内容:
<?php
/**
* The template for displaying all pages
*
* This is the template that displays all pages by default.
* Please note that this is the WordPress construct of pages
* and that other 'pages' on your WordPress site may use a
* different template.
*/
get_header(); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post();
the_content();
endwhile; else: ?>
<p>Sorry, no posts matched your criteria.</p>
<?php endif; ?>
<?php get_footer();
single.php:
<?php
/* The file for displaying single posts */
?>
<?php get_header(); ?>
<?php while ( have_posts() ) : the_post(); ?>
<div class="blog-heading">
<div class="container">
<h1 class="text-center"><?php the_title(); ?></h1>
</div>
</div>
<section class="blog-section">
<div class="container">
<div class="row">
<div class="col-md-8">
<?php $featured_image_url = wp_get_attachment_url( get_post_thumbnail_id( get_the_ID() ) );
if ( ! empty( $featured_image_url ) ) { ?>
<div class="blog-item-thumbnail single">
<?php the_post_thumbnail(); ?>
<div class="blog-item-date">
<?php the_time('m'); ?><br>
<span><?php the_time('M'); ?></span>
</div>
</div>
<?php } else { ?>
<div class="blog-item-date single">
<?php the_time('m'); ?><br>
<span><?php the_time('M'); ?></span>
</div>
<?php } ?>
<div class="blog-item-info">
<ul>
<li><i class="fa fa-user"></i><?php the_author(); ?></li>
<li><i class="fa fa-folder-open"></i><?php the_category(', '); ?></li>
</ul>
</div>
<div class="clear"></div>
<div class="blog-single-nav row">
<div class="col-sm-2 blog-single-nav-previous"><?php previous_post_link('%link', '<i class="fa fa-angle-left"></i> Prev'); ?></div>
<div class="col-sm-8 addthis_inline_share_toolbox"></div>
<div class="col-sm-2 blog-single-nav-next"><?php next_post_link('%link', 'Next <i class="fa fa-angle-right"></i>'); ?></div>
</div>
<div class="blog-single-content">
<?php the_content(); ?>
</div>
<div class="blog-single-nav row">
<div class="col-sm-2 blog-single-nav-previous"><?php previous_post_link('%link', '<i class="fa fa-angle-left"></i> Prev'); ?></div>
<div class="col-sm-8 addthis_inline_share_toolbox"></div>
<div class="col-sm-2 blog-single-nav-next"><?php next_post_link('%link', 'Next <i class="fa fa-angle-right"></i>'); ?></div>
</div>
<div class="blog-single-author row">
<div class="col-sm-2 col-xs-3">
<?php userphoto_the_author_thumbnail() ?>
</div>
<div class="col-sm-10 col-xs-9">
<h5>About <?php echo get_the_author_meta( 'display_name' ); ?></h5>
<p><?php echo get_the_author_meta( 'description' ); ?></p>
</div>
</div>
<div class="blog-single-comments">
<?php echo do_shortcode('[fbcomments width="100%" count="off" num="5"]'); ?>
</div>
</div>
<div class="col-md-4 blog-sidebar">
<?php get_sidebar(); ?>
</div>
</div>
</div>
</section>
<?php endwhile; ?>
<?php get_footer(); ?>
每当我在网址http://www.example.com/blog/my-test-post/上加载单个帖子时,就会使用page.php,而不是single.php。我找不到原因。
答案 0 :(得分:0)
这很有趣。
尝试...
这些只是一些基本的故障排除技巧,可能会引导您朝正确的方向前进。