繁体   English   中英

我想从redux框架中选择两个类别,但是它调用了一个

[英]I want to select two category from redux framework but it calls one

我的代码如下:

采样的config.php

array(
    'id'       => 'opt-select-featured-post-3',
    'type'     => 'select',
    'data'     => 'categories',
    'title'    => __( 
        'Select Category 3rd Columns', 
        'redux-framework-demo' 
     ),
 ),

模板home.php

<?php $my_query = new WP_Query('category_name='.get_cat_name($arefin030201['opt-select-featured-post-3']).'&showposts=1&order=DESC&orderby=id'); ?>
<?php while ($my_query->have_posts()) : $my_query->the_post(); ?>

<h3><?php the_title() ?></h3>

<?php the_content() ?><br><a href="<?php the_permalink(); ?>">more info</a> 

<?php endwhile; ?>  

因此,如果您要选择多个类别,请为您的选择选项设置multi => true。 然后,将为您提供类别ID,您可以进行相应的查询。

如果可以/想要更改模板的该部分,也可以使用WP_Query类别参数 ,并将多个类别作为数组传递。

$query = new WP_Query( 'cat=2,6,17,38' );

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM