我在 Wordpress 循环中工作,只需要按顺序显示帖子 1、4、5、8、9、12、13 等(+3+1r)的特色图像。
我可以设置一个计数器变量并计算帖子,但不确定如何按照上述顺序选择 nth 如果有人可以帮助语法?
$posts = get_posts();
要获取最后一篇文章,请执行以下任一操作
$last_post = array_pop($posts); //removes it from the array
或
$last_post = end($posts); //sets the internal pointer of $posts to the last element
啊,然后简单地使用上面注释中的 for 循环来获取 ID,然后在您现有的 wp 循环中使用if(in_array(get_the_id(),$ids)){//dosomething}