-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

「cat」ではなく間違ったキーを送信していました。->カテゴリのはずです

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 に答える