[英]If statement selecting nth posts in Wordpress loop
我正在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}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.