Filter posts under multiple categories?

WordPress does this automatically if you do http://yoursite.com/?cat=1+2 (where 1 and 2 is category ids) OR http://yoursite.com/?category_name=apples+oranges (where apples and oranges is the slugs) OR something like http://yoursite.com/category/apples+oranges

Display “add to cart” button on every listing in product category page?

You can use the WooCommerce hook woocommerce_after_add_to_cart_button. This hook will add content after the “Add To Cart” button. If the customer clicks on this button, the product should get added to the cart, and the customer should be send to the checkout page. Add the below code in your child theme functions.php /* Create Buy … Read more

How to get child categories of a given Post

To get the child categories of a given parent category slug, use a combination of get_category_by_slug() and get_categories(). The latter function will return an array of category objects matching the specified query arguments array; the former will return the ID of a category, given its slug. So, for example: <?php $motorbike_child_cat_args = array( ‘child_of’ => … Read more

Exclude Child Categories Using wp_list_categories

Instead of excluding child categories, try to get only categories that have no parents (0) $cats = wp_list_categories( array( ‘parent’ => 0 ) ); That should work with no issues. EDIT: get_the_category_list() does not support advanced arguments. Your best bet is wp_get_post_categories($post_id, array(‘parent=>0’)). That will return an array of objects, you have to do the … Read more

Help with multiple dropdown tags search

Does your theme have a search.php to display the results? And if not then create one based on the codex examples or default theme or post the source to your index.php for troubleshooting. Edit: Your search.php is difficult to debug, try following the structure of a default theme, and put something like this in your … Read more

How Can You Exclude Categories From Your RSS Feeds?

It’s been broken since 3.1, see: http://core.trac.wordpress.org/ticket/16622 and also http://wordpress.org/support/topic/wp-31-breaks-rss-customization-via-exclude_category NOTE: Otto’s suggested fix in that thread doesn’t work for me. Ticket suggests patch will go in for 3.1.1 and i can confirm that currently filters on pre_get_posts or parse_query fail for feeds(unfortunately).

WordPress Multisite – global categories

function __add_global_categories( $term_id ) { if ( get_current_blog_id() !== BLOG_ID_CURRENT_SITE || ( !$term = get_term( $term_id, ‘category’ ) ) ) return $term_id; // bail if ( !$term->parent || ( !$parent = get_term( $term->parent, ‘category’ ) ) ) $parent = null; global $wpdb; $blogs = $wpdb->get_col( “SELECT blog_id FROM {$wpdb->blogs} WHERE site_id = ‘{$wpdb->siteid}'” ); foreach … Read more