一些wordpress代码积累
第一个积累:
<?php if (in_category( '7' )): ?> //if语句选择固定IP的显示出来,[7]是栏目ID <?php else : ?> <?php endif ;?>第二个用WP_Query定制显示出不同类型、ID的文章,并且排序
<?php $myqueryargs = array ( 'post_type' => 'post' , 'post_per_page' => 3, 'orderby' => 'date' , 'order' => 'desc' , 'category__in' => array ( 7,8,9 ), ); ?> <?php $myquery = new WP_Query( $myqueryargs ); ?> <?php if ( $myquery -> have_posts()) : ?> <?php while ( $myquery -> have_posts() ): $myquery -> the_post(); ?> <?php the_title(); ?> <?php endwhile ; ?> <?php endif ; ?> <*php wp_reset_postdata(); *>第三个输出自定义栏目代码,输出一个自定义字段的值
<?php echo get_post_meta( $post ->ID, '乐队' ,ture ); ?> 输出所有自定义字段的值 <?php the_meta(); ?>查看更多关于一些wordpress代码积累 - WordPress的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did9054