Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/290.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在WordPress中将文章从我的索引页面转到其他页面(如博客)_Php_Wordpress_Indexing - Fatal编程技术网

Php 如何在WordPress中将文章从我的索引页面转到其他页面(如博客)

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篇帖子 <?

我是WordPress的初学者,我已经创建了index.php,它会自动显示我的帖子。。但是我想在另一个php文件中显示帖子,比如blog.php。。如何检索index.php中显示的相同帖子


场景是,我正在为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文档 它包含不同的示例如何显示文章,包括或排除特定类别中的文章等