foreach( $wpcx_myposts as $post ) : setup_postdata($post);
//中間代碼我不知道的哦
endforeach;
這是foreach的其他寫法
和:
foreach( $wpcx_myposts as $post ) {
setup_postdata($post);
}
壹致,沒有什麽特別的,只是多了壹個endforeach
也就是結束的意思,結束foreach循環
還有 if.... else if ..... else .... endif
for...endfor
while.....endwhile
這是為了照顧壹些從其他編程語言轉過來的童鞋們,所以有這個語法,沒什麽特別,foreach是循環。
$wpcx_myposts as $post 將 $wpcx_myposts 賦予 $post ,讓php自己去遍歷這個$wpcx_myposts 數組,然後調用 setup_postdata($post); 這個函數