WordPress 插件开发 如何一次性输入多个标签Tags搜索文章内容?

WordPress插件开发中,如何实现在前端页面如何同时搜索多个标签?

类似:?tag=tag1+tag2

下面我们给出代码示例:

<?php
/** posts with any of the following tags */   
$query = new WP_Query( 'tag=bread,baking' );

/** posts with all of the following tags */
$query = new WP_Query( 'tag=bread+baking+recipe' );

/** or alternatively */
$query = new WP_Query( array( 'tag_slug__in' => array( 'bread', 'baking' ) ) );

评论

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注