簡體   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