I created a cpt and custom taxonomy associated with it. Lets say custom taxonomy name is Sports. I added terms to it - football, basketball. Now, i want to fetch post titles tagged under football and basketball separately on same page.(Note:- i am using a custom page template to show list of articles from CPT). $args = array( 'post_type' => 'sports', 'tax_query' => array( array( 'taxonomy' => 'sports_category', 'field' => 'slug', 'terms' => 'football' ), ), ); $myquery = new …
After WordPress update to 6 versions receives an issue. receive duplicated terms on function echo wp_kses_post(get_the_term_list($product->get_id(), 'product_cat', '', ', ', '')); and echo wp_kses_post( get_the_term_list( $product->get_id(), 'pa_material', '<li class="material">', ', ', '</li>' )) ? : ''; All work correctly before the update. I found that get_object_term_cache( $post->ID, $taxonomy ); give me duplicated terms What can cause this issue? Plugin or function change? (unable to find detail WP 6 changelog)
I am working on a music site which has custom post types- 'artists', and 'releases'. I have about 3,000 artists, and about 19,000 Releases in my database. It's been suggested to me that I should create a taxonomy term for each release and each artist to eliminate some slow queries on my site. Anyway, I know how to create a new taxonomy, and how to make terms by hand. How can I auto create terms in my release taxonomy, where …
When I use get_the_terms() inside a loop, the whole thing behaves very strangely. Sometimes the terms are included twice or three times and sometimes a post inside of the loop returns only false. I have used get_the_terms() over and over for the last few years without any problems. So i'm quite confused right now. It seems like wp_get_post_terms() and wp_get_post_categories() are getting out the correct data but I would like to know why get_the_terms() is behaving this way inside of …
$taxonomy = $tag->count > 3 ? 'post_tag' : 'category'; $cats_or_tags = $tag->count > 3 ? $tag_ids : $cat_ids; $args = array( 'tax_query' => array( array( 'taxonomy' => $taxonomy, 'field' => 'id', 'terms' => $cats_or_tags The first part of this ternary works when checking the count of posts in a specific tag but the 2nd part doesn't. It's supposed to set the taxonomy and terms values if there's more than 3 posts tagged otherwise when less than 4, display posts from …
I have a custom taxonomy with custom meta. I have added the custom meta values to columns in the admin list page just fine. But if I search for values that are in these columns nothing is found. I'm assuming I need to use pre_get_terms, but am having trouble figuring out how to include the meta in the query. Here is what I am trying to do to test one of the fields, but results are still negative. add_action( 'pre_get_terms', …
I am currently working with woocommerce for wordpress and making a custom plugin. I would like to update the product categories manually through my own admin panel, here is what I have so far: $catTerms = get_terms('product_cat', array('hide_empty' => 0, 'orderby' => 'ASC')); This gets all product categories when looped. I then add checkboxs to the items in the loop like this: <label><input name="" type="checkbox" value="" id="cat_term_<?php echo $catTerm->name;?>" name="cat_term[]" /><?php echo $catTerm->name; ?></label> I then save the terms like …
I'm currently getting the data from a custom taxonomy using this: $terms = get_terms(array( 'taxonomy' => 'my_custom_taxonomy_name', 'hide_empty' => true )); Now, this returns a lot of stuff in each WP_Term object; term_id, name, slug, term_group, term_taxonomy_id, taxonomy, description, parent, count and filter. I only need to get 2 of those: name and slug. How can I filter that query so it doesn't returns all that unused data?
I'm working on a function where I just want to output a button that links to a specific term. I have used get_the_terms and have gotten it to work successfully, but I've been trying get_term and I've have no luck. I want the shortcode to look like this [see_all_products category="bakery"] and output a button that links to it. This is my function so far: function product_category_button($atts) { extract(shortcode_atts(array( 'category' => '', ), $atts)); // if( $category ) : // Vars …
Is it possible to prevent WordPress from encoding URL with terms? I have a sample taxonomy term "iPhone5~iPhone7" and when I use it for the search function, it turns to "iphone5%ef%bd%9eiphone7 " which is not usable when getting the posts for the term. is it possible to prevent url encoding? thanks in advance.
I have a form which allows certain roles to add custom terms to a taxonomy. My taxonomy is called Genre (slug genre) <form method='post' enctype='multipart/form-data'> <input type="text" value="" name="new"> <input type='submit' name='Save'> </form> I have been going around in circles with this for hours. Ive searched for other questions similar and have tried the suggestions. I am using https://wordpress.org/plugins/custom-post-type-ui/ to create the custom taxonomies - Was wondering maybe my script is firing before this plugin does and therefore wp_insert_terms happens …
I have a custom post type with a custom taxonomy (to show some "best practice" examples on my website). On the single-post-page (single-bestpractice.php) I wanted to show all the terms (categories) like this: Parent: Child, Child, Child I tried this code: $customPostTaxonomies = get_object_taxonomies('bestpractice'); if (count($customPostTaxonomies) > 0) { foreach ($customPostTaxonomies as $tax) { $args = array( 'orderby' => 'name', 'show_count' => 0, 'pad_counts' => 0, 'hierarchical' => 1, 'taxonomy' => $tax, 'title_li' => '' ); wp_list_categories( $args ); } …
I'm having a recipe site where every post naturally contains ingredients. Every ingredient is a tag, and I would like to automatically link every ingredient so the user can click on it and see all recipes that uses that certain ingredient. For this to be possible I guess I have to loop through every word in the post, then check if that word is equal to an existing tag, and wrap that word in a hyperlink. But I'm not sure …
i need to display taxonomy terms in a custom post and also in archive / category page of that post type. terms must be from current post or current category https://stackoverflow.com/questions/15502811/display-current-post-custom-taxonomy-in-wordpress code in this thread works for only single post, can i make it work in archive / category page too pls.
I have a custom post type 'downloads' which i have a have a custom template set up to get terms of to begin with. Im now trying to set up my taxonomy template so that it displays sub-categories if there are any, but if not to show posts for that term. Below is what my taxonomy template includes so far and this works fine to the point that it displays the child categories, but it doesnt then show the posts …
I have a custom post type and a taxonomy with children, with a template file named taxonomy-productcategories.php. On this i want to list all children with their posts. Child taxonomy 1 Child taxonomy 1 Post A Child taxonomy 1 Post B Child taxonomy 1 Post C Child taxonomy 2 Child taxonomy 2 Post D Child taxonomy 2 Post E Child taxonomy 2 Post F And so on... I have an example for getting just the Child taxonomy, but i want …
I have a form that visitors use to upload files and fill out information about them and a function that adds those files to the media library and set various fields (including some custom taxonomies) on the media library items based on fields that the visitor filled out in the form. The problem is, I have an email address field. When a visitor fills out the email address field with "[email protected]", what is displayed on the Attachment details screen (as …
I have a custom taxonomy, Events (“event”). Through ACF, this also has a Taxonomy field, “Topic”, linking it to a secondary taxonomy, Topic (“topic”). I want to get_terms() for all Events terms which bear the specific “Topic” term “Media”, which happens to have term ID 422. I know get_terms() can take meta_query, but I don’t understand how to properly get what I need. Both of these return no results… 'meta_query' => array( array( 'key' => 'Topic', 'value' => '422', ) …
I'm going to get several fields from wp_query result. I know about wp_list_pluck() function, but it accepts only one field paramether. How to get several ones if I'd like to take several parameters from each post found? [ Object1 (ID, name, tag), Object2 (ID, name, tag), Object3 (ID, name, tag), etc. ] Thank you for your help afterwards! My code excerpt is here: $search_param = get_param('search_param', null, 'text'); // POST param $term_id = get_term_by('name', "$search_param", 'image_color')->term_id; $args = array( 'post_type' …