Display all Custom taxonomy terms and their relevant custom posts
Display all Custom taxonomy terms and their relevant custom posts
Display all Custom taxonomy terms and their relevant custom posts
Thank you for all the comments! With your help I managed to rule out a standard WordPress issue. I couldn’t find the culprit (As @DaveRomsey suggested, it could be one of the get_terms or get_terms_orderby hooks altering results). In any case, I solved it by sorting the array: $searchedterms = get_terms( ‘category’, array( ‘name__like’ => … Read more
If you want to achieve that, then you need to add creation_date for each taxonomy, hooked with ‘create_category’ (or create_YOURTAXONOMYNAME) function. lets say,for example, you add a new category : add_action( “create_category”, ‘my_func123’, 10, 2 ); function my_func123( $term_id, $tt_id){ update_option(‘my_taxnm_date_’.$term_id, time()); } then later, anytime, you will be able to get the creation date … Read more
Here is the way I did it, add_action(‘the_content’, ‘lm_alpha_order’); function lm_alpha_order($content){ if(is_page(‘alphabetique’)){ $args = array( ‘taxonomy’ => ‘media_tag’, ‘hide_empty’ => true, ‘orderby’ => ‘name’, ‘order’ => ‘ASC’ ); $terms = get_terms(‘media_tag’, $args); $azRange = range(‘A’, ‘Z’); echo ‘<div class=”half left” style=”float:left;padding-left: 2em;”>’; foreach ($azRange as $letter) { $letter_outputs=””; $the_letter =false; //print(“$letter\n”); $count = 0; $ul=”<ul … Read more
I have realised the problem isn’t with the code I have posted and the issue is when the taxonomies are being created. Basically the reason this wasn’t working is because the query_var parameter was set to false when registering the taxonomy. I changed this to true and my filtering started working.
You have to register the taxonomy before you can add terms to a post type. Register the taxonomy after you register the custom post type. If you are not the one that is registering the post type, you will need to find where it is being registered and make sure you register the taxonomy afterwards. … Read more
Filter Term By Parent Term – Custom Post Type
Enter wp_get_object_terms – it accepts an array of object IDs and retrieves all of their (unique) attached terms: $terms = wp_get_object_terms( [ 1, 2, 3 ], ‘category’ ); foreach ( $terms as $term ) echo “$term->name<br />”;
Not sure in what form you need the term/s, but here’s a piece of code that will first get all your posts’ terms, then print them out as linked names. <?php // Get Post Terms $taxonomy_slug = “your-taxonomy”; $terms = get_the_terms( $post->ID, $taxonomy_slug ); if ( !empty( $terms ) ) { foreach ( $terms as … Read more
I was able to resolve this issue by changing the rewrite slug from product-tag to product_tag when registering the taxonomy. It looks like WP does not like the hyphen and prefers the underscore. $args = array( ‘hierarchical’ => false, ‘labels’ => $labels, ‘show_ui’ => true, ‘show_admin_column’ => true, ‘update_count_callback’ => ‘_update_post_term_count’, ‘query_var’ => true, ‘rewrite’ … Read more