Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter thagizmo

    (@thagizmo)

    For others:

    I’m not feeling really happy with it, but I did mange to work around it somewhat. I still have a feeling that I’m fundamentaly doing something wrong regarding setup of the theme… but for now it will work.

    I added an action to my theme that will filter out the “keyword” parameter whenever I’m on a “single” page through:

    function remove_search_keyword_from_query( $query ) {
        if ( $query->is_single() && $query->is_main_query() ) {
            $query->set( 's', '' );
        }
    }
    add_action( 'pre_get_posts', 'remove_search_keyword_from_query' );

    Thread Starter thagizmo

    (@thagizmo)

    Been able to find something more (no solution, but a better “problem”). Seems the custom field has nothing to do with it.

    The normal sql on a permalink page has this:
    SELECT wp_posts.* FROM wp_posts WHERE 1=1 AND wp_posts.post_name = 'mybread' AND wp_posts.post_type = 'bread' ORDER BY wp_posts.post_date DESC

    When I search something in the query, the query becomes:
    SELECT wp_posts.* FROM wp_posts WHERE 1=1 AND wp_posts.post_name = 'mybread' AND (((wp_posts.post_title LIKE '%mysearch%') OR (wp_posts.post_content LIKE '%mysearch%'))) AND wp_posts.post_type = 'bread' ORDER BY wp_posts.post_date DESC

    It seems what I am looking for is a way to kill the automatic url parsing for search queries, when I am on a “single-bread.php” page… should that be needed? I need to keep passing the query to the permalink page, because of a “back to search result page” link, that returns you to the archive page, with the same search string…

    Ben

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