Archive | Snippets

RSS feed for this section

My Personal Collection Of Tips, Tricks and WordPress Best Practices

Remove the Admin Bar From WordPress Public Side

08 April

Add the following snippet to your functions.php to remove the Admin bar from all logged in users except administrators: // Remove the admin bar function dont_show_admin_bar($content) { return ( current_user_can(“administrator”) ) ? $content : false; } add_filter( ‘show_admin_bar’ , ‘dont_show_admin_bar’); Twitter Facebook Google+ LinkedIn

Related Posts By Taxonomy

06 April

Here’s a useful function for displaying all of the related posts in a given taxonomy. I’ve used similar functions in the past in building a shortcode to display a list of the same custom post types that share a common taxonomy. function related_posts_by_taxonomy( $post_id, $taxonomy, $args=array() ) { $query = new WP_Query(); $terms = wp_get_object_terms( […]

Change the Default WordPress Display Name

05 April

When a new user registers, you can change the default population of the Display Name and make it, e.g., Firstname Lastname. Here’s a snippet you can add to your functions.php: // Set Display Name to Firstname Lastname function set_default_display_name( $user_id ) { $user = get_userdata( $user_id ); $name = sprintf( ‘%s %s’, $user->first_name, $user->last_name ); […]

Customize the WooCommerce Breadcrumb HTML Markup

03 April

The easiest way to do this is to override the woocommerce_breadcrumb function. Add something like the following to your functions.php (obviously add whatever changes you want to make to the markup in the appropriate places): // Customize the WooCommerce breadcrumb if ( ! function_exists( ‘woocommerce_breadcrumb’ ) ) { function woocommerce_breadcrumb( $args = array() ) { […]