Add custom post type archives to search results?

How do I get WP search results to include custom post type (CPT) archives? For example, if I have CPT 'career' whose title (in the template php) is ‘Careers’, how do I get search results to include the CPT archive URL (www.my-domain.com/careers) for “careers”, “career”, “jobs”.

I suppose the question might be, can one insert their own results into search, and how?

I am/can optionally use the Relevanssi search plugin as well. I installed that to try and solve this problem, but it seems that alone is not enough.

Thank you for your attention.

4 Answers
4

WordPress will not return a post type archive page in search results. Relevanssi might work, but a slightly easier route is to create a custom page template that lists the career items. Name the page “Careers” and it will show up in search results.

Another advantage to this approach is that the page’s text content can be displayed above the listing of career items, meaning you can manage that in WordPress rather than hard-coding that text in the template.

There are disadvantages as well – paginating the career items is significantly more complex, so you may be tempted to disable pagination entirely and display them all on a single page. If you have dozens or hundreds of items, that is not a good idea.

Leave a Comment