Hook to filter based on form value and insert term
Hook to filter based on form value and insert term
Hook to filter based on form value and insert term
Make custom post type display with custom taxonomy in url
List posts grouped by children of a custom taxonomy
A simple function to count posts did the trick, but this is one more request in DB : function count_posts_in_cat_by_custom_term( $category_ID, $custom_taxonomy_name, $custom_term_id ){ $args = array( ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => -1, ‘category’ => $category_ID, ‘tax_query’ => [ [ ‘taxonomy’ => $custom_taxonomy_name, ‘fields’=>’term_id’, ‘terms’ => $custom_term_id, ] ] ); $posts = … Read more
The following code is partialy taken from the plugin Taxonomy Images and it’s working: function get_taxonomy_image( $atts ) { $atts = shortcode_atts( array( ‘image_size’ => ‘thumbnail’, ‘id’ => ”, ), $atts ); if( ! empty( $atts[‘id’] ) ) { $term = get_term( $atts[‘id’] ); $related_id = 0; if ( isset( $term->term_taxonomy_id ) ) { $related_id … Read more
Alright, problem solved. Turned out to be a pretty basic mistake, actually. All I needed to do was to pass on the queried term as a second parameter in get_field();. I even posted a comment here referencing one of ACF´s docs that explains just that… Turns out I ALREADY had created the taxonomy array $collections, … Read more
As I said, this is doable, but we need to do careful planning as this is quite a heavy operation. On my test installation with a post count of just 13 posts, and 3 terms per taxonomy, the db is visited 20 times and the complete operation takes 0.03613 seconds. I have tried a couple … Read more
This post is super old but I’ll post my solution here in case anyone else stumbles across this. If you’re using Yoast SEO you can hook into their existing implementation (they do this already for categories). function add_variety_primary_term_taxonomy( $taxonomies, $post_type, $all ) { if( $post_type == ‘product’ && isset( $all[‘my_custom_tax’] ) ) { $taxonomies[‘my_custom_tax’] = … Read more
$url = parse_url( $your_url ); $query = $url[‘query’]; $args_arr = array(); parse_str( $query, $args_arr ); if( isset( $args_arr[‘param’] ) ) { $query_string = $args_arr[‘param’]; $query_string .= ‘,value2’; } else { $query_string = ‘value2’; } add_query_arg( ‘param’, $query_string ); That’s completely untested, but you get the concept. Basically, wordpress is gonna want to replace what you … Read more
I’ve added correct indenting to your question, which should make the problem more obvious. The problem is that you meant: foreach ( $state as $state ) update_post_meta($post_id,’state’,$state->name); What you actually put is: foreach ( $state as $state ); update_post_meta($post_id,’state’,$state->name); Which expands to: foreach ( $state as $state ) { // do nothing } //insert post … Read more