• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

CPT custom taxonomy problem

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › Design Tips and Tricks › CPT custom taxonomy problem

This topic is: resolved

Tagged: CPT, Custom Post Type, custom taxonomy, taxonomy links

  • This topic has 8 replies, 2 voices, and was last updated 8 years, 2 months ago by jaiji.
Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • March 21, 2017 at 1:43 pm #203583
    jaiji
    Participant

    Hi

    I have a CPT (artist) with 2 custom taxonomies (stage, day) and their respective templates. I have the taxonomies displayed in the entry-meta which I've hooked in below the post title. All good. Except, when I click the Stage link, it takes me to the archive for that category as intended, but when I click on the Day link, it takes me to the correct permalink (e.g. website-url/day/saturday) but it displays my blog page.

    Here's the code for displaying the taxes, I think the problem must be here but I don't know enough to diagnose. Any tips much appreciated.

    Also (alternatively): is it possible to display the text for each taxonomy without the link? I only really need the text.

    Site's in dev at the moment so no link.

    //* Display multiple custom taxonomy items in the post meta
    add_filter( 'genesis_post_meta', 'afn_display_custom_tax' );
    function afn_display_custom_tax($post_meta) {
    if ( ! is_singular( 'artist' ) ) 
    return;
    $post_meta = '[post_terms taxonomy="stage" before="Where: "]
    [post_terms taxonomy="day" before="When: "]';
    return $post_meta;
    }

    Taxonomy registration:

    $labels = array(
     'name' => 'Day',
     'label' => 'Days',
     'menu_name' => 'Day',
     'all_items' => 'All Days',
     'edit_item' => 'Edit Day',
     'view_item' => 'View Day',
     'update_item' => 'Update Day',
     'add_new_item' => 'Add New Day',
     'new_item_name' => 'New Day',
     );
     
     $args = array(
     'labels' => $labels,
     'hierarchical' => true,
     'label' => 'Days',
     'show_ui' => true,
     'query_var' => true,
     'rewrite' => array( 'slug' => 'day', 'with_front' => true ),
     'show_admin_column' => false,
     );
     register_taxonomy( 'day', array( 'artist' ), $args );
    March 21, 2017 at 6:12 pm #203609
    jaiji
    Participant

    As far as I can tell it's to do with the templates. Strangely, Stages is using the assigned archive-artist.php and displaying as it should. Days is using index.php, even though it's been assigned the same archive-artist.php. Both CPTs are created in exactly the same way, as are the taxonomies (both in a simple plugin) and otherwise behave as expected. There are no other references to 'days' anywhere else.

    I'm assigning the template with this from Sridhar:

    add_filter( 'template_include', 'sk_template_redirect' );
    function sk_template_redirect( $template ) {
    
    	if ( is_tax( 'stage' ) || is_tax( 'day') )
    		$template = get_query_template( 'archive-artist' );
    	return $template;
    
    }

    Is anything obviously wrong with this?

    March 23, 2017 at 4:18 pm #203748
    Brad Dalton
    Participant

    You need to name the files correctly using the WordPress Template Hierarchy.

    Example taxonomy-artist.php however this depends on how you coded the CPT

    And remove the code for template_include.


    Tutorials for StudioPress Themes.

    March 23, 2017 at 4:51 pm #203751
    jaiji
    Participant

    Thanks Brad. I don't get how it works fine for one category but not the other though?

    March 23, 2017 at 4:55 pm #203752
    Brad Dalton
    Participant

    Are you using categories or custom taxonomy types for your CTP?

    My solution is tested using custom taxonomy types.


    Tutorials for StudioPress Themes.

    March 23, 2017 at 5:22 pm #203755
    jaiji
    Participant

    Also the template redirect is working and the first taxonomy 'stage' is using the arist-archive.php just fine, it's just the second that isn't.

    March 23, 2017 at 5:54 pm #203757
    jaiji
    Participant

    Sorry Brad, I missed your earlier reply. I'm using custom taxonomies. The template redirect works for one of them though, as intended, which is why I'm confused. Could a custom taxonomy template be the same (content-wise) as the main CPT archive template, just named and titled to suit?

    March 23, 2017 at 6:41 pm #203759
    jaiji
    Participant

    I've just uploaded two category archive templates and removed the template_include, and flushed permalinks. Same problem, 'stages' works and 'days' goes to the blog. I have flushed permalinks.

    Especially frustrating as I don't actually want or need the archives, I just need their names displayed on the CPT in the entry meta but I don't know how to strip out the links.

    March 24, 2017 at 11:23 am #203775
    jaiji
    Participant

    Fixed. The problem was using 'Day' as one of the terms, which I now know is a query var reserved for use by WordPress. I changed the term name, menu name, the arg label and the rewrite slug to 'when' instead, then re-added the relevant terms to the CPT and all is good. The template rewrite is working fine too.

  • Author
    Posts
Viewing 9 posts - 1 through 9 (of 9 total)
  • The forum ‘Design Tips and Tricks’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2025 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble