0

This is my first real delve into custom post types and taxonomies, i suppose it will all come to me in a flash of inspiration but right now i have confused myself beyond all realms of possibility and need some advice as whether im going on the right track.

heres what i have:

Three custom post types, namely:

sale
rental
business

all the above share 2 taxonomies (location and region) and then they have their own specific taxonomies too.

Now im looking at template files for each of the Custom Post Types and also template files for the taxonomies.

So of course i headed over to WP Codex and checked out custom post type templates, now if i understand correctly to template each of my custom post types i should use *archive-*name_of_post_type.php and *single-*name_of_post_type.php for when in single post view.

Ok so up to here i reckon im ok, now this is where im confused, off to Codex Again this time to find out how to add a template to each of the taxonomies, codex tells me this *taxonomy-*name_of_taxonomy.php, now a couple of questions if i may:

1) am i going about this the correct way

2) is the taxonomy template a single view (ie like single.php) or a looped view, im guessing its looped like categories.

3) can i create just one template and include all taxonomies (via an if statement to shake through seperate loop files?)

regards Martin

1 Answer 1

1
  1. Looks like you got the hang of it.

  2. Taxonomy template is an archive of posts that share a term just like categories or tags, so if by looped view you mean archive then yes you are correct.

  3. you can create just one template that will include all taxonomies and use the get_template_part function to include the correct loop.

3
  • phew thats what i wanted to here many thanks, i ran a heck of a lot of tests with my new archives,taxonomy and singles files and all seems pretty good, im having just one issue with search (taxonomy drill down widget by scribu) seems to be bypassing search.php and going straight to index.php and pulling the loop-home.php in from there and returning everything, is the reason its not calling search.php (with my loop-search.php call) something to do with custom post types or a seperate matter all together?
    – MartinJJ
    May 20, 2011 at 12:59
  • when dealing with search you have a whole section of the codex you need to understand first codex.wordpress.org/Creating_a_Search_Page
    – Bainternet
    May 20, 2011 at 13:21
  • cheers bainternet, i understand all that with the search.php, my problem with search is sorted now, (like i say its custom post types and tax's that were getting the better of me). My search problem wasnt really a problem as such.. i needed to take a look into Template Hierarchy to see what what the issue was... regards Martin
    – MartinJJ
    May 21, 2011 at 13:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.