0

I have a CPT called campsites and in there I have different categories ie. derbyshire, staffordshire, nottinghamshire etc. What I want to do is that when you click on a category eg. derbyshire, ideally I'd like it to say at the top of the page Campsites in derbyshire.

Please help.

1
  • Are you using the category taxonomy specifically, or a custom taxonomy? Please post your register_post_type() code and any applicable, related code (such as register_taxonomy() and/or register_taxonomy_for_object_type(). Commented Nov 26, 2012 at 14:18

1 Answer 1

2

From what I understand, you just need to use this in your template as it sounds like you will be using an archive page for a given CPT.

<h1><?php post_type_archive_title(); ?></h1>

I've not been able to test this but you can find more info about the options on this Wordpress Codex page.

http://codex.wordpress.org/Function_Reference/post_type_archive_title

There are other solutions based on how your page is going to be displayed so feel free to give more info if this doesn't work.

Based on your comment, you may be able to use a simple tag like this...

<h1><?php echo single_cat_title(); ?></h1>

If it still won't play you may need to go slightly more in depth and I'll need to do that from my main computer later as I have done this same thing recently.

3
  • Hi I just tried that and it didnt work. Basically i want to have the title of the CPT category in this template taxonomy-camps_categories. So for example if someone go in to campsites (CPT) and click on the derbyshire category, it will show all the campsites in derbyshire and i want to have the title at the top saying campsites in derbyshire. Is this possible?
    – mandy
    Commented Nov 26, 2012 at 13:49
  • Hi @mandy , check the update above - hopefully it will be this easy. If it is still a no go I'll hook out my solution later. I did this same thing recently ;-)
    – shanem
    Commented Nov 26, 2012 at 14:11
  • Glad to hear it ;-)
    – shanem
    Commented Nov 27, 2012 at 10:51

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.