0
我正在創建一個搜索結果頁面,我試圖排除特定的帖子格式。我發現這個查詢,但我不知道如何使後循環的作品,我甚至不知道代碼。而且,我不知道如何在404上找不到search.php。
這是代碼
<?php
$args = array(
'tax_query' => array(
array(
'taxonomy' => 'post_format',
'field' => 'slug',
'terms' => 'post-format-quote', 'post-format-video',
'operator' => 'NOT IN'
)
)
);
query_posts($args);
?>
我第一次嘗試的東西和工作正常,但如果我設置「每頁4後」,它計算所有的格式後,如果在搜索結果的標準帖子應該是3和1格式的帖子,它顯示3個標準帖子和一個空白空間。
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<?php if(get_post_format() == 'quote') : ?>
<?php elseif(get_post_format() == 'link') : ?>
<?php elseif(get_post_format() == 'video') : ?>
<?php elseif(get_post_format() == 'image') : ?>
<?php else : ?>
post
<?php endif; ?>
<?php endwhile; else : ?>
<?php get_template_part('partials/content', 'none'); ?>
<?php endif; ?>
也許是因爲當帖子格式爲報價時你什麼都不做?請發佈整個代碼,而不是它的一部分。 – Gal