• I am pulling my hair out trying to create a custom taxonomy template and am hoping someone here can tell me what I am missing.

    I am using the twentytwelve theme.

    I want to add a custom taxonomy for Locations. I’ve done this using this tutorial from Smashing Magazine. https://wp.smashingmagazine.com/2012/01/04/create-custom-taxonomies-wordpress/

    Now, I want to create archive pages. If a visitor clicks on domain.com/locations/california, it should show the archive for all posts with that taxonomy.

    I followed the next step in the tutorial and created taxonomy-locations.php. The file includes the following code:

    get_header();
    $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );

    At first, I copied and pasted the smashing mag code, but this didn’t work. Instead of showing posts in “california”, it simply showed my most recent posts.

    I’ve looked at a dozen other tutorials and attempted a dozen other taxonomy-locations.php files, but nothing works. I cannot get the archive pages to show.

    Am I missing something? Is there an extra step I need to take? Like creating another page or template? Is this an issue with the twentytwelve theme itself?

    Here is the site I’m working on… https://www.testingbaret.com/locations/east-bay/ (shows index.php)

    https://www.testingbaret.com/locations/east-bay/danville (shows a random post with the word “danville” in it. No idea how this is happening)

    I’ve also tried naming the file locations.php and that makes no difference.

    Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Frances

    (@francesjanecampbellgmailcom)

    I created an archive-custom-post-type-name file to display all custom posts in an archive.
    I have a taxonomy applied to my custom post type called ‘event_topics’ – To see archives by topic – I can’t get taxonomy-taxname-termname.php type templates to work – however, if I just rely on the archive page then I can get only the posts under the ‘term’ name showing in my archive for a given term.

    The problem then is that I only have the excerpt on the archive page, I don’t have any of my custom fields – so I’d need to add code to display these in as conditionals in ‘content.php’ which seems wrong and messy to me. I tried creating taxonomy-taxname-termname pages but they didn’t work they just showed all posts. I’m also wondering if – or _ in the termname or taxname messes things up template hierarchy wise. Basically also stumped!

    Frances

    (@francesjanecampbellgmailcom)

    (I have done taxonomy templates previously with other themes – this is specific to 2012 unless I’m totally missing something!)

    As per the Forum Welcome, please post your own topic. Posting in an existing topic prevents us from being able to track issues by topic.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘taxonomy template help’ is closed to new replies.