|
魔扣币兑换比例:【 50以下 : ¥1 = 10 魔扣币 】丨【 50 - 100 :¥1 = 20 魔扣币】丨【 100以上:¥1 = 30 魔扣币 】
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?立即注册
x
有时候我们需要为网站添加一个自定义文章类型,但是当访问此文章类型页面时,如何获取相关联的文章呢?请看以下代码:
- $terms = get_the_terms( $post->ID , 'product_tags', 'string');
- $term_ids = wp_list_pluck($terms,'term_id');
- $second_query = new WP_Query( array(
- 'post_type' => 'products',
- 'tax_query' => array(
- array(
- 'taxonomy' => 'product_tags',
- 'field' => 'id',
- 'terms' => $term_ids,
- 'operator'=> 'IN' //Or 'AND' or 'NOT IN'
- )),
- 'posts_per_page' => 3,
- 'ignore_sticky_posts' => 1,
- 'orderby' => 'rand',
- 'post__not_in'=>array($post->ID)
- ) );
- if($second_query->have_posts()) {
- while ($second_query->have_posts() ) : $second_query->the_post();
- //loop
- endwhile; wp_reset_query();
- }
复制代码 看以上代码即可知道方法,哈哈哈~~小白请绕道或联系魔扣科技开发
|
|