简体   繁体   中英

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

My code is below:

Sample-config.php

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

Template-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; ?>  

So if you want to select multiple categories, set multi=>true to your select option. Then you will be provided with the category IDs and you can query accordingly.

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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