Taxonomy Template for custom Taxonomy in Portfolio

Hi,

I managed to register in functions.php a fully functional custom taxonomy "custom_tags" to my Portfolio.

However, the archive pages for this taxonomy will not display the default Portfolio Archive Taxonomy template, but the Blog one.

I have some questions, to understand the way Betheme is working to replicate / modify a Template,

1) Should I work with a copy of taxonomy-portfolio-types.php OR template-portfolio.php?

2) Should I make create a new template, i.e. portfolio-tags.php or modify the file?

3) Would be enough to substitute the "portfolio_classe" for my "custom_tags"?

4) Do I need to register it in some other theme template?




As reference here my code in functions.php for a custom Taxonomy for Betheme Portfolio:


/*** Add PORTFOLIO Taxonomy ***/

add_action( 'init', 'create_custom_tag_taxonomies', 0 );

//create two taxonomies, genres and tags for the post type "tag"

function create_custom_tag_taxonomies() 

{

 // Add new taxonomy, NOT hierarchical (like tags)

 $labels = array(

  'name' => _x( 'Tags', 'taxonomy general name' ),

  'singular_name' => _x( 'Tags', 'taxonomy singular name' ),

  'search_items' => __( 'Search Tags' ),

  'popular_items' => __( 'Popular Tags' ),

  'all_items' => __( 'All Tags' ),

  'parent_item' => null,

  'parent_item_colon' => null,

  'edit_item' => __( 'Edit Tag' ), 

  'update_item' => __( 'Update Tag' ),

  'add_new_item' => __( 'Add New' ),

  'new_item_name' => __( 'New Tag Name' ),

  'separate_items_with_commas' => __( 'Separate tags with commas' ),

  'add_or_remove_items' => __( 'Add or remove tags' ),

  'choose_from_most_used' => __( 'Choose from the most used tags' ),

  'menu_name' => __( 'Tags' ),

 ); 

 register_taxonomy('custom_tags','portfolio',array(

  'hierarchical' => false,

  'labels' => $labels,

  'show_ui' => true,

  'update_count_callback' => '_update_post_term_count',

  'query_var' => true,

  'rewrite' => array( 'slug' => 'ukv' ),

 ));

}




Thanks in advance,

Miguel

Comments

  • Hello,

    1) You should use a copy of taxonomy-portfolio-types.php because the other file is responsible only for displaying the main Portfolio page.

    2) The better option will be creating a new template because you will know what changes you made and how it suppose to work.

    3) If you are doing only this slight change, then it will be enough.

    4) If you want to modify the theme files, the best option is to use a child theme. Thanks to that, your modifications will not be lost after an update, and you can customize the files without fear of breaking something in these files.

    To learn more about the child theme, please, check the following link:

    https://support.muffingroup.com/documentation/installation-updates/#child-theme


    Please, also check the following guide about creating your custom taxonomies in WordPress:

    https://developer.wordpress.org/themes/basics/categories-tags-custom-taxonomies/


    Thanks

  • edited March 2021

    Thank you Phil,

    This is giving me some clarity :)

    And yes, I am doing it on my child theme.

  • edited March 2021

    Hi Phil,

    I created a copy of taxonomy-portfolio-types.php, named taxonomy-portfolio-tags.php (according to my custom taxonomy "tags" that I added to functions.php), made the following changes, and placed it on the root of my child theme:

    • 'taxonomy' => 'portfolio-types' -------> 'taxonomy' => 'tags' (x2)
    • $portfolio_types_query -------> $portfolio_tags_query

    As far as I know, I don't see anything else I need to change for my custom taxonomy.

    However the template for the portfolio tags won't be read by the child theme, it keeps displaying the template for blog.

    Do I need to call or register this taxonomy-portfolio-tags.php somewhere else?

    Thanks in advance, Miguel

  • Sorry, but it is not really Betheme related question.

    I can help you find where is a particular file, but I cannot help you with file customization because it is not allowed in reference to the Item Support Policy: http://themeforest.net/page/item_support_policy.

    If you need help with it, I recommend you to visit the following link:

    https://wpkraken.io/?ref=muffingroup


    Thanks

Sign In or Register to comment.
This website uses cookies

We use cookies to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners who may combine it with other information that you’ve provided to them or that they’ve collected from your use of their services.

Cookies are small text files that can be used by websites to make a user's experience more efficient.

The law states that we can store cookies on your device if they are strictly necessary for the operation of this site. For all other types of cookies we need your permission. This means that cookies which are categorized as necessary, are processed based on GDPR Art. 6 (1) (f). All other cookies, meaning those from the categories preferences and marketing, are processed based on GDPR Art. 6 (1) (a) GDPR.

This site uses different types of cookies. Some cookies are placed by third party services that appear on our pages.

You can at any time change or withdraw your consent from the Cookie Declaration on our website.

Learn more about who we are, how you can contact us and how we process personal data in our Privacy Policy.

Please state your consent ID and date when you contact us regarding your consent.