Customize my custom taxonomy table in Admin panel

This should do the trick: add_action( ‘admin_print_styles’, ‘cor_admin_print_styles’, 200 ); function cor_admin_print_styles() { $screen = get_current_screen(); if ( ‘edit-tags’ === $screen->base && ‘department’ === $screen->taxonomy ) { echo <<<EOF <style> .fixed .column-posts { width: auto; } .widefat .num, .column-comments, .column-links, .column-posts { text-align: left; } </style> EOF; } }

Grey out nav buttons unless is_user_logged_in()

When you look at the possible arguments, then you’ll see that there’s as well the option to add a custom nav menu walker class. $defaults = array( ‘theme_location’ => ”, ‘menu’ => ”, ‘container’ => ‘div’, ‘container_class’ => ”, ‘container_id’ => ”, ‘menu_class’ => ‘menu’, ‘menu_id’ => ”, ‘echo’ => true, ‘fallback_cb’ => ‘wp_page_menu’, ‘before’ … Read more

Globally register styles but enqueue them selectively

If you want the stylesheets registered in the backend, use the admin_enqueue_scripts action. function wp94156_register_styles() { wp_register_style( ‘your-stylesheet’, get_stylesheet_directory_uri() . ‘/your-stylesheet.css’, $deps, // optional $version // optional ); // since you only want it registered, we won’t enqueue it } add_action( ‘admin_enqueue_scripts’, ‘wp94156_register_styles’ );

Add CSS to head depending on nav menu walker

Call wp_nav_menu() before wp_head() is called, and store the result for later usage: <head> <?php $menu = wp_nav_menu( array( ‘echo’ => FALSE, ‘theme_location’ => ‘primary’, ‘walker’ => new Special_Walker ) ); wp_head(); ?> </head> <body> <?php echo $menu; Now you can enqueue the CSS from your custom walker. In your walker collect all CSS rules … Read more

WordPress CSS doesn’t update

Sounds like your Template has 2 style sheets, one that is unused. By default WordPress will look for style.css in the editor but this doesn’t necessary mean its used in the header.php Take a look at your source code and view which css files are being loaded. I suspect your see it something like: /wp-content/themes/your-theme/css/blah.css … Read more

Add a class to posts in increments of 2

Filter post_class, use a static internal counter in the filter callback: add_filter( ‘post_class’, ‘wpse_100804_post_class’ ); function wpse_100804_post_class( $classes ) { static $counter = 0; $counter += 1; switch ( $counter ) { case 4: $counter = 0; case 3: $classes[] = ‘extra’; } return $classes; } In your loop template call post_class() like this: while … Read more

Highlight wp_nav_menu when category is selected

one solution to your problem using jQuery( put this code in functions.php ) <?php add_action(‘wp_footer’,’ravs_browse_menu’); function ravs_browse_menu(){ if(isset($_GET[‘cat’]) && $_GET[‘cat’] !=”){ ?> <script> jQuery(document).ready(function(){ jQuery(‘#menu-item-299’).addClass(‘current-menu-item’); }); </script> <?php } } ?>

How to Add Custom CSS Buttons to WordPress as a Shortcode?

function myButton($atts, $content=””){ extract(shortcode_atts(array( ‘text’ => ”, ‘link’ => ” ), $atts)); $html=”<a href=”” . $link . ‘”><div class=”myButton”>’ . $text . ‘</div></a>’; return $html; } add_shortcode(‘mybutton’, ‘myButton’); Add this to your functions.php and you will be able to call the button within wordpress using the shortcode you wanted. As you can see the class … Read more

Output terms to post_class()

The easiest and most straight-forward way to do this would be: $tax_terms = get_the_terms( $post->ID, array(‘genre’) ); $tax_terms = wp_list_pluck($tax_terms,’slug’); post_class(implode(‘ ‘,$tax_terms)); You could also apply a filter to post_class that does essentially the same. function tax_classes_wpse_105386($classes) { global $post; $tax_terms = get_the_terms( $post->ID, array(‘genre’) ); $tax_terms = wp_list_pluck($tax_terms,’slug’); $classes = array_merge($classes,$tax_terms); return $classes; } … Read more