php WordPress插件分类类别和帖子排序


php Wordpress plugin taxonomy category and posts sorting

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

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

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

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

query_posts( array ( 'categories' => $category_id, 'posts_per_page' => -1, 'post_type' => 'portfolio', 'post_status' => publish, 'orderby' => 'title', 'order' => 'ASC' ) );