-1

我正在使用在管理面板中具有内置投资组合选项卡的主题。这个主题使用投资组合项目和投资组合类别而不是原始帖子项目和类别。

我已经构建了一个插件,可以从投资组合的分类中列出列表 - “类别”

<?php $portfolio_cats = get_terms( 'Categories', $args); ?>
    <?php foreach ($portfolio_cats as $cat) { echo "<option value = '".$cat->name."'>".$cat->name."</option>"; } ?> </select> <input style = "height: 35px;

并希望通过类别 ID 过滤与所选类别无关的所有帖子。

<input style = "height: 35px;
padding: 10px 45px;" type = "submit" value = "הצג" /> </form>
   <table class="widefat" style = "margin: 0 auto;width: 908px;">
        <thead>
            <tr>
                <th>Category</th>
                <th>Name</th>
            </tr>
        </thead>
        <tbody>
        <?php
            $category_id = get_cat_ID(''.$_POST['filter'].'');
            $q = 'cat=' . $category_id;
            query_posts($q);
            if (have_posts()) : while (have_posts()) : the_post(); ?>
           <tr> <td> <?php echo $_POST['filter']; ?> </td> <td> <a href="<?php the_permalink();?>"><?php the_title(); ?></a> </td> </tr>

           <?php endwhile; endif; ?>
        </tbody>
    </table> 

但无论如何,它总是向我展示相同的原始帖子,而不是投资组合的帖子。

任何帮助将不胜感激。

更新: 它现在显示每个投资组合项目,但是它仅在启动时显示,当我选择类别并运行搜索过滤器时,它什么也不显示

<input style = "height: 35px;
padding: 10px 45px;" type = "submit" value = "הצג" /> </form>
   <table class="widefat" style = "margin: 0 auto;width: 908px;">
        <thead>
            <tr>
                <th>Category</th>
                <th>Name</th>
            </tr>
        </thead>
        <tbody>
        <?php
            $category_id = $_REQUEST['filter'];
            /* $q = 'cat=' . $category_id; */
            query_posts( array ( 'cat' => $category_id, 'posts_per_page' => -1, 'post_type' => 'portfolio' ) );
            if (have_posts()) : while (have_posts()) : the_post(); ?>
           <tr> <td> <?php echo $_POST['filter']; ?> </td> <td> <a href="<?php the_permalink();?>"><?php the_title(); ?></a> </td> </tr>

           <?php endwhile; endif; ?>
        </tbody>
    </table> 
4

1 回答 1

-1

我发送了一个错误的密钥,而不是“猫”,它应该是 ->类别

query_posts( array ( 'categories' => $category_id, 'posts_per_page' => -1, 'post_type' => 'portfolio', 'post_status' => publish, 'orderby' => 'title', 'order' => 'ASC' ) );
于 2012-08-26T08:12:33.187 回答