jodlajodla (@jodlajodla)

Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • In reply to: Limit search on forum

    jodlajodla
    Participant

    @jodlajodla

    I found out that I misunderstood your post. I downloaded plugin that you suggested and checked the code. I remembered that I used is_bbpress() somewhere and that was the solution for my problem. There’s the snippet of code that I used in my theme in file functions.php:

    /* Do not search pages, only posts and if there's a request from bbPress or Admin panel than ignore setting of post type */
    function search_filter($query) {
    	if ($query->is_search && !is_admin() && !is_bbpress()) {
    		$query->set('post_type', 'post');
    	}
    	return $query;
    }
    add_filter('pre_get_posts', 'search_filter');

    Thank you very much again! 🙂 🙂

    In reply to: Limit search on forum

    jodlajodla
    Participant

    @jodlajodla

    You are right. There’s a problem because WordPress filters all searches, including the bbPress. Now I don’t know how to recognize if the search is coming from WordPress’s search box or bbPress’s searchbox.

    I don’t need search box for forum on first/home page, but I need to filter results when searching with WordPress’s search box. I must not show pages in it, so that’s why I’m searching solution.

    Thank you!

Viewing 2 replies - 1 through 2 (of 2 total)