hide specific categories from showing

I haven’t tested this, so it might need to be tweaked (specifically, I’m not sure if I got the names of the params right on the term object), but this should get you most of the way there. //add filter add_filter( ‘get_the_terms’, ‘my_exclude_terms’, 10, 1 ); //function to do filtering function my_exclude_terms( $terms ) { … Read more

Select category in custom query

I would do this in two pieces. Add this into your functions.php file to grab custom fields globally: function get_custom_field($key, $echo = FALSE) { global $post; $custom_field = get_post_meta($post->ID, $key, true); if ($echo == FALSE) return $custom_field; echo $custom_field; } Build your query as follows: I can’t seem to get markdown to play nice, so … Read more

Disable pagination only for specific category

You can try this, replacing my_cat with your category slug. This will modify the main query just before rendering the loop on the archive page of your category. add_action( ‘pre_get_posts’, ‘wpse_disable_pagination’ ); function wpse_disable_pagination( $query ) { if( is_category( ‘my_cat’ ) { query->set( ‘posts_per_page’, ‘-1’ ); } }

Categories and Tags returning 404 on the sidebar when using ugly permalinks

Instead of: home_url() . “/tag/” . $i->slug Use get_term_link() function. It will return the link for the term according with the current configuration: // Assuming $i is a term object get_term_link( $i->term_id ) For example, your printTags() function would be: function printTags($tags){ //Check to see if tags are provided if ($tags!=false) { $return = ”; … Read more

How can I make wp_list_categories output li with category-slug as class, for its children?

I am not sure if querying the categories again is the good idea. The following code extends the Walker_Category and makes use of it to do the replacement. Put the following in your functions.php: class WPSE67791_Walker_Category extends Walker_Category { public function start_el(&$output, $category, $depth, $args) { parent::start_el( $output, $category, $depth, $args ); $find = ‘cat-item-‘ … Read more

Order posts by category name

I had the same struggle like you, thank i sat down and rethought the whole thing, what you actually need to is select all the categories, and pass the category id to it. Since you use a dlm_download you will need to do the following, get the terms from the dlm_download_category $cats = get_terms(‘dlm_download_category’); Loop … Read more

Does WordPress Offer a Way to Find All of the Categories that Don’t Have Children?

There is no way easy way to do that. You have to query directly to achieve that. I am assuming, you only want the parent categories which don’t have descendants or even if they have descendants, it’s not used in any post global $wpdb; $categories = $wpdb->query(“SELECT $wpdb->terms.* FROM $wpdb->terms INNER JOIN $wpdb->term_taxonomy ON $wpdb->terms.term_id … Read more

WooCommerce – Display product child categories from specific parent

The woocommerce function get_categories() is declared in abstract-wc-product.php, because it is based on the wordpress function get_the_term_list() there is no way to get only a specific branch of a category. This absolutely isn’t the same as the wordpress function get_categories(), you can see that it is woocommerce specific by how it’s used $product->get_categories(). Besides the … Read more