Hide terms if they aren’t the same as the current term
If you are on a term archive page, you already have the term object available to you via get_queried_object: $term = get_queried_object(); echo get_term_link( $term ); echo $term->name;
If you are on a term archive page, you already have the term object available to you via get_queried_object: $term = get_queried_object(); echo get_term_link( $term ); echo $term->name;
get_the_terms() will help you. Function return array with terms objects and you can foreach array and retrieve term id for each term attached to post.
You didn’t add the dropdown/select name attribute, that’s why it’s not working as expected. Please try updating your $dropdown_args, here’s the updated arguments – $dropdown_args = array( ‘taxonomy’ => ‘cs_categories’, ‘id’ => $this->get_field_id( ‘cs-category’ ), ‘name’ => $this->get_field_name( ‘cs-category’ ), // Added this line ‘show_option_none’ => __( ‘Select category’, ‘text-domain’ ), ‘hide_empty’ => true, ‘hierarchical’ … Read more
The values parsed out of internal rewrites don’t end up in GET, you have to use get_query_var(‘search_location’) instead. If you have code that you can’t edit that relies on GET, you can try to set them manually- function wpd_foo_get_param() { if( false !== get_query_var( ‘search_location’ ) ){ $_GET[‘search_location’] = get_query_var( ‘search_location’ ); } } add_action( … Read more
From the help of the comments above I needed to use get_term_terms to print the ID. I used the code below to achieve what I needed: <?php $terms = get_the_terms( $post->ID, ‘producers_assessment’ ); foreach($terms as $term) {?> <?php $image = get_field(‘badge’, ‘producers_assessment_’ . $term->term_id); if( !empty($image) ): ?> <img src=”https://wordpress.stackexchange.com/questions/295839/<?php echo $image[“url’]; ?>” alt=”https://wordpress.stackexchange.com/questions/295839/<?php echo … Read more
Ah, I found it. I just need to give a unique name to each term (so for the external URLs, I named them url-[md5] where [md5] is the MD5 hash of the URL), and then call add_term_meta and set the necessary information, then add this term to the post using my custom taxonomies. For example, … Read more
The error message is pretty clear: Invalid taxonomy.. You’re hooking to init to register your custom taxonomy, however you’re calling get_terms( ‘type’ ) right away, before init is fired and therefore before your taxonomy is registered. You can’t call get_terms( ‘type’ ) before init.
You’d do something like $current_user = wp_get_current_user(); to get the current user, then you’d want their posts $current_user_posts = get_posts(array( ‘author’ => $current_user->ID, ‘posts_per_page’ => -1 ); with their posts, you’d cycle through them, and grab the terms $current_user_terms = array(); foreach ($current_user_posts as $user_post) { $user_terms = wp_get_post_terms($user_post->ID, ‘custom_tax’, array(“fields” => “ids”)); foreach ($user_terms … Read more
I know this is old but I ran across this issue, adding true to the end of the hook resolved the issue. In this instance wp_remove_object_terms($postID, ‘remove_this_term’, ‘custom_taxonomy’, true); will run the hook.
$category_detail=get_the_category(get_the_ID());//$post->ID foreach($category_detail as $cd) { $name_cat=$cd->cat_name; $id_cat=$cd->term_id; } try now this code