Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/262.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.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 将帖子限制为特定类别和子类别_Php_Wordpress_Categories - Fatal编程技术网

Php 将帖子限制为特定类别和子类别

Php 将帖子限制为特定类别和子类别,php,wordpress,categories,Php,Wordpress,Categories,在这个网站上:我使用了一个程序员来定制模板。他的本页代码为: <?php $args = array( 'numberposts' => 18, 'post_status'=>"publish",'post_type'=>"post",'orderby'=>"post_date"); $postslist = get_posts( $args ); echo '<ul id="latest_stories">'; foreach ($pos

在这个网站上:我使用了一个程序员来定制模板。他的本页代码为:

<?php 

$args = array( 'numberposts' => 18,   'post_status'=>"publish",'post_type'=>"post",'orderby'=>"post_date");

$postslist = get_posts( $args );

echo '<ul id="latest_stories">';

foreach ($postslist as $post) :  setup_postdata($post); ?> 

<li><a href="<?php the_permalink(); ?>" title="<?php the_title();?>">

<span class="s_thumb"> <?php the_post_thumbnail( 'full' ); ?> </span>

<span class="s_title"> <?php the_title(); ?> </span></a>

<span class="s_cotegories">More Stories from <?php the_category( ', ' ); ?></span></li>

<?php endforeach; ?>

  • 更多故事来自

  • 这些帖子应该限制在一个特定的类别(#82)及其子类别内。我知道如何使用传统的post显示来实现这一点:但由于我没有编写这段代码,我不知道如何修改它。

    您可以在数组中设置过去的类别以获取帖子

    $args = array( 'numberposts' => 18, 'post_status'=>"publish",'post_type'=>"post",
    'orderby'=>"post_date", category=>82);
    

    您可以将数组中的类别设置为“过去”,以获取\u帖子

    $args = array( 'numberposts' => 18, 'post_status'=>"publish",'post_type'=>"post",
    'orderby'=>"post_date", category=>82);