WP REST API – Limit the taxonomy search to the first letter

You can use the rest_names_query filter to handle the custom starts_with REST API parameter, and use the terms_clauses filter to add a custom SQL clause for searching terms having their name starting with the specified letter (e.g. A or a for /wp/v2/names/?starts_with=A): add_filter( ‘rest_names_query’, function( $args, $request ){ if ( ‘/wp/v2/names’ === $request->get_route() && // … Read more

Get child product categories from parent product category in WooCommerce

Edited (1) You will need to use ‘child_of’ from WP_Term_Query available arguments, that will let you to get all child terms for the current product category parent term: // Only on product category archive pages if( is_product_category() ) { $main_term = get_queried_object(); $args_query = array( ‘taxonomy’ => ‘product_cat’, ‘hide_empty’ => false, ‘child_of’ => $main_term->parent ); … Read more

Create multiple rewrite endpoints for custom taxonomy archive

This code above works fine up to one endpoint but not working for multiple endpoints like following https://example.com/dogs/shop/prod-cat1 https://example.com/dogs/shop/prod-cat2 https://example.com/cats/shop/prod-cat1 https://example.com/cats/shop/prod-cat2 Uses template shop-cat.php & value of query variable i.e prod-cat1, prod-cat2 available on template Your request hook callback is always setting the query var to true, like so (for the shop var): if (isset($vars[‘shop’])) … Read more

List taxonomies in a dropdown in theme’s option panel

A taxonomy is a group of terms. I think you registered a taxonomy Catalogs, and now you want to list all terms in this taxonomy. You do that with the function get_terms(), not get_taxonomies(). So your $wp_tax array should be filled like this: $wp_tax = array(-1 => ‘Choose a category’); $catalog_terms = get_terms(‘Catalogs’); if ($catalog_terms) … Read more

showing custom taxonomies w/custom post type

For the dashboard post listing bit…. http://codex.wordpress.org/Plugin_API/Action_Reference/manage_posts_custom_column // ADDS EXTRA INFO TO ADMIN MENU FOR PRODUCT POST TYPE add_filter(“manage_edit-ve_products_columns”, “voodoo_prod_edit_columns”); add_action(“manage_posts_custom_column”, “voodoo_prod_custom_columns”); function voodoo_prod_edit_columns( $columns ) { // Add the extra column for product categories instead of rebuilding the whole array $columns[‘prod_cat’] = “Product Category”; $columns[‘description’] = “Excerpt”; return $columns; } function voodoo_prod_custom_columns( $column ) … Read more

Creating an Archive using a Custom Taxonomy

you can add the current term to you query so if its category, tag or custom taxonomy you will get the posts with the current term, try changing this: query_posts(‘cat=0&posts_per_page=12&paged=’.$paged); with this: $term_slug = get_query_var( ‘term’ ); $taxonomyName = get_query_var( ‘taxonomy’ ); query_posts(array(‘posts_per_page’ => 12, ‘paged’ => $paged, $taxonomyName => $term_slug));

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)