Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

Jake Bolton
Jake Bolton
1,956 Points

I was hoping someone could help, I'm trying to find a tutorial for creating a search results page in Wordpress? Thanks

I'm developing a custom Wordpress theme and need to create a template to list results from a general search box. This should list results from all post types on the site.

I'm really looking for a tutorial, either on Treehouse or elsewhere.

Many thanks, Jake

5 Answers

Cosmin Cioaclă
Cosmin Cioaclă
21,339 Points

Hi Jake,

There is a course on Theme Development right here on treehouse, but it is not very in-depth on how to do specific tasks (a search page, for example). The scope is more broad, with emphasis on how things are connected in Wordpress, and where to go look for more info on how you can make it your own.

In short, whenever you search for something using the wordpress search form, the results are shown using the search template. That is handled by the search.php file. If your theme doesn't have one, you can grab your archive.php file and save it as search.php, modifying it further to suit your needs. More info on this is found on the Wordpress codex.

Hope that helps, Cosmin

Jake Bolton
Jake Bolton
1,956 Points

Hi Cosmin,

Thanks for your comment. I have tried to create a search results template from the page.php template as I don't actually have an archive.php template. But I've struggled with this. Also using that same tutorial.

I was trying to find a more detailed tutorial on the code syntax.

I've tried copying the code from the search.php in another theme but struggling to change the details to make it work.

Is there another area that I need to address beyond the code in the template for search.php?

Many thanks, Jake

Cosmin Cioaclă
Cosmin Cioaclă
21,339 Points

Hi Jake,

The search.php template completely controls how search results are displayed. If are struggling to customize it, I recommend taking the Wordpress Theme Development Course available here in order to get a better grasp on the tools you need for your endeavor.

Jake Bolton
Jake Bolton
1,956 Points

Hi Guys,

Thanks for your help on this, I eventually managed to get this sorted.using the searchform.php template type and then calling it using get_search_form() object into the sidebar.php

Thanks for your help with this guys.

Cheers, Jake