Shopify Free Trial Apply
Shopify 60天试用
Shopify 14天试用

archive页面一个模板调用不同文章类型

先定义一个文章类型变量,$type,这样就不用每个文章类型单独做一个archive模板,当然前提框架一样

<?php 
$type = $wp_query->query['post_type']; // if is archive page, get type, use "$wp_query->query['post_type']" instead of "$post -> post_type"
?>

<?php
//if a type need taxonomy sidebar, use this code
$paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
$query_args = array(
'post_type' => $type,
'posts_per_page' => '15',
'orderby' => 'title',
'order' => 'ASC',
'post_status' => 'publish',
'paged' => $paged
  );
  // create a new instance of WP_Query
$the_query = new WP_Query( $query_args );
?>



<?php wp_reset_query();?>
1
2018-09-27

1 个评论

隽永智库好久没有发布文章了,感谢一直为智库努力的你。

要回复文章请先登录注册