Custom color for each category name

To achieve this Follow these easy step: Add field for color To Add/Edit category Screen using hooks category_add_form_fields and category_edit_form_fields add_action(‘category_add_form_fields’, ‘my_category_fields’, 10, 2); add_action(‘category_edit_form_fields’, ‘my_category_fields’, 10, 2); function my_category_fields($term) { $cat_color = get_term_meta($term->term_id, ‘cat_color’, true); if($cat_color == ”) $cat_color=”#000000″; // Default black color ?> <tr class=”form-field”> <th valign=”top” scope=”row”><label for=”cat_color”><?php _e(‘Color code’); ?></label></th> <td> … Read more

Remove child products from woocommerce category page [closed]

you want to display only parent category products and remove the child category products. Add the following lines of code at the end of your theme’s functions.php file. function exclude_product_cat_children( $wp_query ) { if ( isset( $wp_query->query_vars[‘product_cat’] ) && $wp_query->is_main_query() ) { $wp_query->set( ‘tax_query’, array( array ( ‘taxonomy’ => ‘product_cat’, ‘field’ => ‘slug’, ‘terms’ => … Read more

Highlight current category in wp_list_categories

This will add a current-cat class to any / all categories connected to the post, not jut one. Add this to functions.php function tax_cat_active( $output, $args ) { if(is_single()){ global $post; $terms = get_the_terms( $post->ID, $args[‘taxonomy’] ); foreach( $terms as $term ) if ( preg_match( ‘#cat-item-‘ . $term ->term_id . ‘#’, $output ) ) $output … Read more

Create a full width responsive header image per page

John there are lots of ways to do this, depending on what you want exactly and how much experience you have with html/php/css (or how much time you’d want to spend learning). There are plenty of plugins on wordpress that could achieve this. You might want to just try some of them out: https://wordpress.org/plugins/search.php?q=custom+header If … Read more

Update term count using a callback function

I think I’ve worked this out. First of all, you need to define your taxonomy. I’m pulling this code directly from the codex; however, I’ve added one parameter update_count_callback. I’ve set this to the cleverly titled my_update_count_callback. This just specifies that when a post of type post (this will be whatever CPTs you associate the … Read more

How to display a list of categories

I will show you how to display a list of categories in WordPress and also mark the active category, see code below: <?php // Get the current queried object $term = get_queried_object(); $term_id = ( isset( $term->term_id ) ) ? (int) $term->term_id : 0; $categories = get_categories( array( ‘taxonomy’ => ‘category’, // Taxonomy to retrieve … Read more

How to make a relationship between books and authors?

To build relationships, I know of two plugins, both very well coded and maintained: Posts 2 Posts Efficient many-to-many connections between posts, pages, custom post types, users. Advanced Custom Fields – this one would need the add-on Users Select, but as the plugin is being completely rewritten and will change the add-on management, it would … Read more