Custom Post Type Base URL
You need the has_archive option set to true when registering your custom post type with the register_post_type function, in order for the archive-{posttype}.php file to work.
You need the has_archive option set to true when registering your custom post type with the register_post_type function, in order for the archive-{posttype}.php file to work.
after_setup_theme is the wrong action to register post types. See register_post_type in Codex: Do not use register_post_type before init.
It’s not necessarily a fix, but you should be able to use the Rewrite Analyzer plugin to help you understand how WP is rewriting your links.
According to the function definition, wp_get_object_terms() throws an error if it can’t find your taxonomy – and returns an empty array if there aren’t any taxonomy terms attached to that post. Have you made sure you’ve assigned a prod_cat to the custom post you’re looking at?
It can be daunting to wrap your head around these things sometimes. I sure had a hard time with it 🙂 You were right making the Restaurant a custom post type which you can then assign terms from your the custom taxonomies. First of all, it would be best if you change the names of … Read more
It sounds like making a custom post type called “Products” would be the best way for you to manage the products. Unless you want a special name for the taxonomy, you could just make your custom post type use the default “Category” taxonomy for organizing your products. The simplest way to add data like article … Read more
If the code above is how it is in your actual theme file, there are obvious errors (maybe it didn’t post right here). Here is the fixed code: <?php add_filter(‘post_type_link’, ‘my_permalink_structure’, 10, 4); function my_permalink_structure($post_link, $post, $leavename, $sample) { if ( false !== strpos( $post_link, ‘%states%’ ) ) { $term = get_the_terms( $post->ID, ‘states’ ); … Read more
If you’re trying to create a output template, then yes essentially just replace the word cat or category everywhere in that code with the word tag. Something is still missing from this question though because template_portfolio.php isn’t a standard template name and it’s not clear how it’s being called by your custom theme.
I was able to solve this by ordering my taxonomy values based on this post: Custom taxonomy, get_the_terms, listing in order of parent > child
The is_tax() function checks if a custom taxonomy archive page is being displayed. So it will only work in template files such as taxonomy-product_cat.php – unless you create new templates for specific categories in the product_cat taxonomy. For example, if you have a product category called “Toasters” and the slug is “toasters” then the template … Read more