I have blog with some post and pages and a forum, i need a search such that it need to search tags in post and pages and not in forum (bbpress)

if ($query->is_search()) {
    $postType = array();
    $tagPostType = array();
    $tags = array();
    if (isset($_GET['taglist']) && is_array($_GET['taglist'])) {
        $tagPostType = array('page','post');
        $postType = array_merge($postType, $tagPostType);
        $tags = $_GET['taglist'];
     } else {
         $postType =  array('forum','topic','reply','page','post');
     if(isset($_GET['forums'])) {
         $tags = '';
         $postType = array_merge($tagPostType, array('forum','topic','reply'));
     $query->set('tag_slug__in', $tags);
     $query->set('post_type', $postType);
    return $query;

i need to search tags in post/pages and not in forums.

  • 1
    Welcome at WPSE. Have you already had a look at What topics can I ask about here? and How do I ask a good question? WordPress unfortunately doesn't make this possible out of the box. You'd either need a plugin (which would be off topic to ask for at WPSE) or code it yourself. Then you'd need to add some research and code to your question. Please have a look at the links above. – kraftner Jun 10 '14 at 9:58
  • You want to search posts, pages, and forums in general, but only search tags for posts and pages? – s_ha_dum Jun 10 '14 at 15:57
  • Got the answer i made functions usng the filters add_filter('posts_join', 'forum_search_join'); – Akhilraj N S Jun 13 '14 at 7:54

You can use filters to create custom search querys

add_filter('posts_join', 'forum_search_join')
add_filter('posts_where', 'forum_search_where');



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.