Excerpt Ending

function new_excerpt_more($more) { return ‘…’; } add_filter(‘excerpt_more’, ‘new_excerpt_more’);  

Read More

Add parent page slug to body_class

/*************************************************************** * Function body_class_section * Add the top level page to the body class for coloured sections ***************************************************************/ add_filter(‘body_class’,’body_class_section’); function body_class_section($classes) { global $wpdb, $post; if (is_page()) { if ($post->post_parent) { $parent = end(get_post_ancestors($current_page_id)); } else { $parent = $post->ID; } $post_data = get_post($parent, ARRAY_A); $classes[] = ‘section-‘ . $post_data[‘post_name’]; } return $classes; } This […]

Read More

Grab all 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; } Then call the field with a single line <?php get_custom_field(‘custom-field-name’, TRUE); ?>

Read More

Change the “Howdy” message to “Welcome”

This is what is running on this site: function change_howdy($translated, $text, $domain) { if (!is_admin() || ‘default’ != $domain) return $translated; if (false !== strpos($translated, ‘Howdy’)) return str_replace(‘Howdy’, ‘Welcome’, $translated); return $translated; } add_filter(‘gettext’, ‘change_howdy’, 10, 3);   With this function you can customize the “Howdy” message in top right of your admin area. This […]

Read More

Custom Admin Footer

// customize admin footer text function custom_admin_footer() { echo ‘add your custom footer text and html here’; } add_filter(‘admin_footer_text’, ‘custom_admin_footer’); I use this for client sites as a simple point of reference to contact me as the dev.

Read More

Restrict ADMIN menu items based on username or NOT ADMIN

function remove_menus() { global $menu; global $current_user; get_currentuserinfo(); if($current_user->user_login == ‘username’) { $restricted = array(__(‘Posts’), __(‘Media’), __(‘Links’), __(‘Pages’), __(‘Comments’), __(‘Appearance’), __(‘Plugins’), __(‘Users’), __(‘Tools’), __(‘Settings’) ); end ($menu); while (prev($menu)){ $value = explode(‘ ‘,$menu[key($menu)][0]); if(in_array($value[0] != NULL?$value[0]:”” , $restricted)){unset($menu[key($menu)]);} }// end while }// end if } add_action(‘admin_menu’, ‘remove_menus’); //alternatively you can use if($current_user->user_login != ‘admin’) instead, […]

Read More

Style the tag cloud

//tag cloud custom add_filter(‘widget_tag_cloud_args’,’style_tags’); function style_tags($args) { $args = array( ‘largest’ => ’10’, ‘smallest’ => ’10’, ‘format’ => ‘list’, ); return $args; }

Read More

Remove “Read More” page jumps**

Instead return to the top of the page. You know how when you click “read more” it will jump to the spot in the page which can be annoying, this makes it just load the page normally, no jumping! function remove_more_jump_link($link) { $offset = strpos($link, ‘#more-‘); if ($offset) { $end = strpos($link, ‘”‘,$offset); } if […]

Read More