Hide post category name wherever it might be mentioned

Yes, you can use the wp_get_object_terms filter to remove the hidden category from any list that uses default WordPress methods like wp_get_post_categories(). add_filter(‘wp_get_object_terms’, ‘wpse_remove_unwanted_category’, 10, 4); function wpse_remove_unwanted_category($terms, $object_ids, $taxonomies, $args) { // we’re only interested in category, if this is another taxonomy if ($args[‘taxonomy’] !== ‘category’) { // return early return $terms; } // … Read more

Media Library Categories

I found a solution! My code changed quite a bit… Here is what the functions.php file looks like (which did not change): function wptp_add_categories_to_attachments() { register_taxonomy_for_object_type( ‘category’, ‘attachment’ ); } add_action( ‘init’ , ‘wptp_add_categories_to_attachments’ ); But here is the new code in footer.php, which returns the images from the Media Library, but only from an … Read more

Hide empty category on woocommerce

By your code i’m assuming your $child is the id of an term, the term object is being stored in the $term variable, so you can do this: <?php if( $term->count > 0 ): ?> <li><a href=”https://wordpress.stackexchange.com/questions/274628/<?php echo get_term_link( $child,”product_cat’ )?>”><?php echo $term->name; ?></a></li> <?php endif; ?>

Post url rewriting for posts with certain category

generate_rewrite_rules didn’t work for me at all and I found posts on forums where others were having the same issue. Adding to the rewrite_rules_array did work. Below is the solution. add_filter( ‘post_link’, ‘custom_permalink’, 10, 3 ); add_filter(‘rewrite_rules_array’,’wp_insertMyRewriteRules’); add_filter(‘init’,’flushRules’); function custom_permalink( $permalink, $post, $leavename ) { $category = get_the_category($post->ID); if ( !empty($category) && $category[0]->cat_name == “Shop” … Read more

Default URL for category dropdown select option

I found a solution! As I was looking for a fix I ran across this article: https://andrux.net/add-empty-option-to-wp_dropdown_categories/ This is very close to what I was looking for, so I tweaked it. The only thing I did to the form was remove the show_option_none=Select… The form code: <form action=”<?php bloginfo(‘url’); ?>” method=”get” id=”catform”> <?php $parent = … Read more