Custom Search Results Page

I was able to do this in Canvas, but can’t figure out so far how to do this in the BB theme. I’m using the Search Everything plugin, which works nicely, for my WP searching. The BB theme does not have native search.php or search-content.php files, so I created my own using the BB core files and renamed them accordingly.

The problem I’m running into is the search results. I’m using several custom post types, with their own customized templates. I want to be able to click on the search results title and go to the actual custom post type template for single results, not the very bland BB search results. For instance, if I do a search for “wordpress”, and it’s found in custom post types “example1”, “example2”, etc, but I click on the results for “example1” post type, I’d like the single results to be for that post type. It appears that the BB searching takes you to the same template for everything on the site. Are there supposed to be some “if” statements for post types and templates in the code somewhere?

The site is still in development, so not publicly available.

Any suggestions?

Hey Dairrell! Thanks for the heads up on this. It’s a bit tough to wrap my head around without being able to see it. :slight_smile:

I have an idea, though, could you try temporarily activating one of the default, twentyX themes and see if they handle search results similarly to Canvas? If there’s an improvement we can make on our end to make this better for you, we definitely want to know!

[Content Hidden]

I’m no PHP guru, and I’d be lying if I understood everything I do when messing with PHP. But I did figure out the problem for displaying the proper post type for each search.

It turned out to be a simple fix (after hours of working with it).

In the single.php file, I changed this line of code:

<?php get_template_part(‘content’, ‘single’); ?>

to this:

<?php get_template_part( ‘content’, get_post_type() ); ?>

Now if a keyword search (like “wordpress”) shows up in the results under more than one post type, you can click on each result and be taken to the post/page, and if you have customized the post type template/page, it will show up with the proper customizations, rather than the plain BB default file.

Hopefully that will help someone else running into the same issue.

Dairrell, that’s great! I am so glad to hear you got it figured out and thanks a ton for sharing. I’ll make sure our dev team sees this in case there’s something we can do on our end to make it easier.

Sorry I couldn’t get back to you sooner, too.