[英]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.