search.php及びsingle.phpでの特定カテゴリの除外
-
search.php及びsingle.phpでの特定カテゴリの除外についてお聞きしたいのですが、投稿検索結果にある特定のカテゴリ(ここではcat=34)に属する投稿を除外したいので、query_postでcat=-34などを試したのですが、全く反応せず、検索も機能しなくなりました。
<?php if (have_posts()) : ?> <h2 class="pagetitle"><?php _e('Search Results'); ?>"<?php the_search_query(); ?>"</h2> <?php while (have_posts()) : the_post(); ?> <div class="entries"> <ul><a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a></ul> <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2> <li><?php the_excerpt(); ?></li> <li2>カテゴリー:<?php the_category(', '); ?> | <?php the_date_xml(); ?></li2> </div> <?php endwhile; ?>
上記がsearch.php内のコードです。
また、同じことを、各投稿(single.php)でもしたいのですが、”古い記事”リンクナビゲーションで表示したくないカテゴリの記事がでてきてしまいます。
インデックスでの最新記事リストでは、、query_postのcat=-34でうまく行きましたが、search.phpとsingle.phpでうまくいかないのはなぜでしょうか?
簡単な事かもしれませんが、よろしくお願いします。
3件の返信を表示中 - 1 - 3件目 (全3件中)
3件の返信を表示中 - 1 - 3件目 (全3件中)
- トピック「search.php及びsingle.phpでの特定カテゴリの除外」には新たに返信することはできません。