📜  Wordpress 偶数奇数帖子计数 - 任何代码示例

📅  最后修改于: 2022-03-11 14:57:24.637000             🧑  作者: Mango

代码示例1
post_count && ( $wp_query->post_count % 2 ) == 1 ) {
            // if final count is reached AND final count is odd
            // full width item
            $postclass = "fullwidth";
            $opentag = '';
            $closingtag = '
'; } else if ( ( $count % 2 ) == 1 ) { // if $count is odd it is the first item in a 'row' $postclass = "halfwidth first"; $opentag = '
'; $closingtag = ''; } else { // second item in a row $postclass = "halfwidth second"; $opentag = ''; $closingtag = '
'; } ?>
CONTENT OF POST : Title, Thumbnail, Excerpt... etc