Php 在wordpress中查看帖子

Php 在wordpress中查看帖子,php,wordpress,Php,Wordpress,我用这段代码列出了我在wordpress中插入的index.php <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $args = array( 'post_type' => 'post', 'posts_per_page' => 10, 'paged' => $paged ); $wp_query = new WP_Query($args); while ( have_posts

我用这段代码列出了我在wordpress中插入的
index.php

<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array( 'post_type' => 'post', 'posts_per_page' => 10, 'paged' => $paged );
$wp_query = new WP_Query($args);
while ( have_posts() ) : the_post(); ?>
    <h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
<?php endwhile; ?>

<!-- then the pagination links -->
<?php next_posts_link( '&larr; Older posts' ); ?>
<?php previous_posts_link( 'Newer posts &rarr;' ); ?>


我的链接以
http://localhost/?p=314
一旦我点击链接,我会看到一个非常不整洁的页面。当我看到twentyeleven主题时,我看到了single.php,但我不知道它是如何用来显示帖子的。如果是,我需要一个模板,例如
view.php
single.php
来显示帖子,如何?

是的,您需要对single.php进行更改,以重新格式化这些帖子的显示方式

请注意,您可以在设置->永久链接中将永久链接从默认值(?p=314)更改为搜索引擎经常优化的永久链接。

阅读下面的url

WordPress提示:如何在任意位置显示特定帖子


我把这段代码放在
single.php
文件中,文章现在显示的和预期的一样

   <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
      <?php the_content();?>
      <?php endwhile;?>
      <?php endif; ?>


wordpress如何知道single.php将用于显示单击的帖子?。在普通的crud安排中,您可以明确地说single.php?p=314。这里有一个链接,指向wordpress模板层次结构的工作方式-感谢链接,这节省了时间。