New answers tagged

1

You should no longer use the legacy function parameter format. Instead, as the documentation says, use the get_terms( $args ) format: Since 4.5.0, taxonomies should be passed via the ‘taxonomy’ argument in the $args array: $terms = get_terms( array( 'taxonomy' => 'post_tag', 'hide_empty' => false, ) ); And as for getting only the terms assigned ...


0

Instead of showing custom field with text, create a custom field with select dropdown. Populate that dropdown options with get_terms function (term_id as value) Add multiple attribute to select if you need to store more than one term relation. Store values as array of term ids On frontend loop trough saved array and use get_term function to get term ...


0

You can use ACF (Advanced Custom Fields) plugin to do this. Select Taxonomy field and set the field group to appear where you need to. I'm pretty sure the free version of the plugin has this field.


2

You actually correctly assigned the tag to the post, but the taxonomy is pets_tag, so you shouldn't use get_the_tags() which is for the default post_tag taxonomy. Instead, you should use get_the_terms() to get the pets_tag terms assigned to the post: $terms = get_the_terms( 3356, 'pets_tag' );


0

I would suggest you hand-build the navigation menu using the selected taxonomy terms, not using a script to automatically add them, which is where you would have problems with new terms being added.


1

I've found the problem, and now I realise I had this exact same problem years ago on a different project: This: 'exclude_from_search' => true Needed changing to: 'exclude_from_search' => false 'has_archive' => true, I don't get why excluding a post type from search should affect archive templates, but at least it's fixed now.


0

I wanted to display the terms with the get_the_term_list function so, since categories & taxonomy have a "similar logic", I replaced the "the_category_list" add_filter( 'the_category_list', 'ci_theme_the_category_list_remove_parent_categories', 10 ); with "get_the_terms" add_filter( 'get_the_terms', '...


Top 50 recent answers are included