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

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 unwanted dashboard items

This was already posted but it did not have the full list of items. Especially those annoying “incoming links!” add_action(‘wp_dashboard_setup’, ‘my_custom_dashboard_widgets’); function my_custom_dashboard_widgets() { global $wp_meta_boxes; //Right Now – Comments, Posts, Pages at a glance unset($wp_meta_boxes[‘dashboard’][‘normal’][‘core’][‘dashboard_right_now’]); //Recent Comments unset($wp_meta_boxes[‘dashboard’][‘normal’][‘core’][‘dashboard_recent_comments’]); //Incoming Links unset($wp_meta_boxes[‘dashboard’][‘normal’][‘core’][‘dashboard_incoming_links’]); //Plugins – Popular, New and Recently updated WordPress Plugins unset($wp_meta_boxes[‘dashboard’][‘normal’][‘core’][‘dashboard_plugins’]); //Wordpress Development Blog […]

Read More

Customize the Dashboard

add_action(‘wp_dashboard_setup’, ‘my_custom_dashboard_widgets’); function my_custom_dashboard_widgets() { global $wp_meta_boxes; Remove these dashboard widgets… unset($wp_meta_boxes[‘dashboard’][‘normal’][‘core’][‘dashboard_plugins’]); unset($wp_meta_boxes[‘dashboard’][‘side’][‘core’][‘dashboard_primary’]); unset($wp_meta_boxes[‘dashboard’][‘side’][‘core’][‘dashboard_secondary’]); Add a custom widget called ‘Help and Support’ wp_add_dashboard_widget(‘custom_help_widget’, ‘Help and Support’, ‘custom_dashboard_help’); } This is the content for your custom widget function custom_dashboard_help() { echo ‘<p>Lorum ipsum delor sit amet et nunc</p>’; }

Read More

Customize the order of the admin menu

tested on: WordPress 3.0.1 This code will allow you to reorganize the order of elements in the admin menu. All that you need to do is click on an existing link in the admin menu and copy everything before the /wp-admin/ URL. The order below represents the order the new admin menu will have. // […]

Read More