0
我想通过使用它的slug名称(例如'最受欢迎')来获取所有职位在一个类别下。我该怎么做呢?得到一个类别的所有职位id按类别slug
这是我试过的,但失败了。
<?php
global $post;
$id = array();
$i=0;
$args = array('numberposts' => 5, 'category' => "most-popular", 'post_status' => "publish", 'order'=>"ASC");
$myposts = get_posts($args);
foreach($myposts as $post) :
setup_postdata($post);
$id[$i]=$post->ID;
$i=$i+1;
endforeach;
$article1= new Article($id[0]);
$article2= new Article($id[1]); //and so on.
?>