简体   繁体   English

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

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

My code is below: 我的代码如下:

Sample-config.php 采样的config.php

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

Template-home.php 模板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. 因此,如果您要选择多个类别,请为您的选择选项设置multi => true。 Then you will be provided with the category IDs and you can query accordingly. 然后,将为您提供类别ID,您可以进行相应的查询。

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

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

暂无
暂无

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

相关问题 我想一并发送我选择查询的json响应 - I want to send json response of my select query two in one 我想限制它只添加一个类别的产品,不允许其他人使用 woocommerce - I want to limit it to add only products from one category and not allow others with woocommerce PHP:两个 <select> ,第一个已经准备好填充,第二个我想填充值 - PHP: Two <select>, first one allready fill, the second one I want to fill with values 我想按类别在两个不同的列中显示记录 - I want to show record in two different columns by category 如何将两个Post / Category表MYSQL SELECT查询合并为一个 - How to combine two Post/Category tables MYSQL SELECT queries into one SQL:如果没有帖子从另一类别中选择,则仅按一个查询按类别选择一个帖子 - SQL: SELECT one post by category if no posts select from another category only one query LARAVEL-我想从类别对象访问包含主要类别ID的上层_id列的主要类别 - LARAVEL - I want to access the main category from the category object with the upper _id column that contains the main category ID CakePHP:如何使用“漂亮”网址选择一个类别的所有元素? (/类别/ NAME_OF_CATEGORY) - CakePHP: How can I select all elements of one category with a “nice” url? (/category/NAME_OF_CATEGORY) Redux框架,Wordpress,从所有帖子类型中选择页面/帖子 - Redux framework, Wordpress, Select page/post from all post types Redux Framework从选择字段获取文本,而不是ID(密钥) - Redux Framework get text from select field instead of id (key)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM