Php 如何在WordPress中将文章从我的索引页面转到其他页面(如博客)
我是WordPress的初学者,我已经创建了index.php,它会自动显示我的帖子。。但是我想在另一个php文件中显示帖子,比如blog.php。。如何检索index.php中显示的相同帖子Php 如何在WordPress中将文章从我的索引页面转到其他页面(如博客),php,wordpress,indexing,Php,Wordpress,Indexing,我是WordPress的初学者,我已经创建了index.php,它会自动显示我的帖子。。但是我想在另一个php文件中显示帖子,比如blog.php。。如何检索index.php中显示的相同帖子 场景是,我正在为show开发主题,我想在我的博客页面中创建一些功能,比如没有边栏、左侧边栏、右侧边栏。。。但是我的主页(index.php)包含帖子。。每当我用相同的编码(如blog.php)启动新页面时,它都不会显示index.php的帖子。此示例代码从categpry id 4检索3篇帖子 <?
场景是,我正在为show开发主题,我想在我的博客页面中创建一些功能,比如没有边栏、左侧边栏、右侧边栏。。。但是我的主页(index.php)包含帖子。。每当我用相同的编码(如blog.php)启动新页面时,它都不会显示index.php的帖子。此示例代码从categpry id 4检索3篇帖子
<?php
$args = array( 'numberposts' => 3, 'order'=> 'DESC', 'orderby' => 'post_date', 'category' => 4 );
$postslist = get_posts( $args );
foreach ($postslist as $post) : setup_postdata($post);
$a= get_the_date();
?>
<h1><?php the_title(); ?></h1>
<p><?php the_content(); ?></p>
<?php endforeach; ?>
参考WordPress文档
它包含不同的示例如何显示文章,包括或排除特定类别中的文章等