Use get_the_terms to list subcategories of custom taxonomy

When you use get_the_terms() it returns a term object. One of the fields is ‘parent’ which stores the ID of the term parent. So you can compare the current term’s parent to the parent term that you are looking for. $desired_parent_name=”fruits”; $desired_parent_id = get_term_by(‘name’, $desired_parent_name)->term_id; foreach ($terms as $term) { if $term->parent == $desired_parent_id { … Read more

Print terms with taxonomy and metabox value

Try This: $args = array( ‘hide_empty’ => false, ‘relation’ => ‘OR’, array( ‘key’ => ‘serial_language’, ‘value’ =>’english’, ‘compare’ => ‘LIKE’ ), array( ‘key’ => ‘serial_language’, ‘value’ =>’arabic’, ‘compare’ => ‘LIKE’ ), ‘taxonomy’ => ‘serial’, ); $terms = get_terms( $args ); hope this will help

List Post Title by Last Word Then Second Last

I think I got it!!! Try this: $orderby = ” SUBSTRING_INDEX( {$wpdb->posts}.post_title, ‘ ‘, -1 ) ” . $get_order. ” , {$wpdb->posts}.post_title ” . $get_order; Basically it’s sorting by lastname and then first name in 1 query. So, your whole code would be: add_filter( ‘posts_orderby’, function( $orderby, \WP_Query $q ) { if( ‘wpse_last_word’ === $q->get( … Read more

Should the actual /category/ directory be 404? Is that normal WP behaviour

Yes, it’s normal behavior. WordPress uses a set of rewrite rules to process requests. Here are the rules that will match requests related to categories: [category/(.+?)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?category_name=$matches[1]&feed=$matches[2] [category/(.+?)/(feed|rdf|rss|rss2|atom)/?$] => index.php?category_name=$matches[1]&feed=$matches[2] [category/(.+?)/page/?([0-9]{1,})/?$] => index.php?category_name=$matches[1]&paged=$matches[2] [category/(.+?)/?$] => index.php?category_name=$matches[1] As you can see, all of them require, that the request is longer than /category/. And it makes … Read more

Filter WooCommerce admin products list by a custom taxonomy

There is some missing parts in your code: Try the following: add_action(‘restrict_manage_posts’, ‘admin_products_by_manufacturer_filter_dropdown’); function admin_products_by_manufacturer_filter_dropdown() { global $typenow, $pagenow; $taxonomy = ‘vyrobca’; // The custom taxonomy if( ‘edit.php’ === $pagenow && ‘product’ === $typenow && taxonomy_exists( $taxonomy ) ) { $info_taxonomy = get_taxonomy($taxonomy); $selected = isset($_GET[$taxonomy]) ? $_GET[$taxonomy] : ”; wp_dropdown_categories( array( ‘show_option_all’ => sprintf( … Read more