Tag Info

Hot answers tagged

1

I wouldn't call it a bug, you haven't done anything to place that restriction on the query for your post. It also seems like a fairly unlikely case where random strings will end up in place of your taxonomy terms for this to even present itself. Anyway, the answer is to modify the query via pre_get_posts to add in whatever taxonomy data you need. I don't ...


1

You are missing a link. The posts are not assigned to the menus directly. There is a post type nav_menu_item in nav_menu taxonomy which links posts (or other kinds of destinations) to their place in menu. This snippet should get you started on retrieval: $menu_items = get_posts( [ 'post_type' => 'nav_menu_item', 'meta_query' => [ [ ...


1

You can get the current term slug from the global query. You could do something like this: if( is_tax('cars') ) { //We are in "cars" taxonomy archive page, now get the queried term $term = get_query_var( 'term' ); show_post($term); }


1

Adding a NOT EXISTS clause should force LEFT JOINs: 'meta_query' => array( 'relation' => 'OR', array('key' => 'file_gallery', 'value' => '1', 'compare' => '!='), array('key' => 'file_gallery', 'compare' => 'NOT EXISTS'), ),


1

get_terms returns an array of objects. You cannot echo an array, if you do, you will just get Array(). What you can do is print_r($array) or var_dump($array) or echo json_encode($array) to see the data it contains. Otherwise, to get single elements, e.g. the name, from the objects, you need to pass $tax_terms through a foreach loop to get the objects from ...


1

If using get_the_terms, you can just do your if loop once for each taxonomy and then join them after the three loops. Of course, it would probably be more efficient to use: wp_get_post_terms( $post_id, $taxonomy, $args ); You could then do something like: wp_get_post_terms( $post_id, array( 'resource_roles', 'resource_media', 'resource_theme' ) ); ...



Only top voted, non community-wiki answers of a minimum length are eligible