我刚刚开始进行Wordpress模板开发,已经习惯了。
但是我一直想在这里找到解决方案,但找不到相同的问题。
我想对类别和后格式进行过滤,我有以下代码,对后格式的过滤器有效,但是对类别不起作用。
$videos = new WP_Query( array(
'tax_query' => array(
array(
'taxonomy' => 'post_format',
'field' => 'slug',
'terms' => array(
'post-format-video'
),
'category_name=instructie-videos',
'posts_per_page=6',
'operator' => 'IN'
)
)
) );
$videos = new WP_Query( array(
'post_type' => 'your-post-type',
'posts_per_page' => 6,
'category_name' => 'instructie-videos',
'tax_query' => array(
array(
'taxonomy' => 'post_format',
'field' => 'slug',
'terms' => array( 'post-format-video' ),
'operator' => 'IN'
)
)
) );
也许是category_name
附近的语法错误。试试上面的代码
您应该尝试以下操作:
$myposts = new WP_Query( array(
'tax_query' => array(
array(
'taxonomy' => 'post_format',
'field' => 'slug',
'terms' => array(
'post-format-aside',
'post-format-audio',
'post-format-chat',
'post-format-gallery',
'post-format-image',
'post-format-link',
'post-format-quote',
'post-format-status',
'post-format-video'
),
'operator' => 'NOT IN'
)
)
) );