Thord Daniel Hedengren - Smashing WordPress_ Beyond the Blog-Wiley (2014)

(avery) #1

228 PART IV • Additional Features and Functionality


is what you’re looking for. To remove the excerpts box on posts, use this code in functions.
php or in a plugin if you feel that this is something that needs to stay portable across
themes:

function smashing_remove_post_excerpt() {
remove_meta_box( 'postexcerpt' , 'post' , 'normal' );
}
add_action( 'add_meta_boxes' , 'smashing_remove_post_excerpt' );

This function uses remove_meta_box(), plus the add_meta_boxes hook, which loads
on the Edit screen in the WordPress admin.

You can even remove widgets that you just don’t want your users to end up littering the site
with, also in functions.php or from a plugin:

function smashing_unregister_widgets(){
unregister_widget( 'WP_Widget_Calendar' );
unregister_widget( 'WP_Widget_Meta' );
}
add_action( 'widgets_init', 'smashing_unregister_widgets' );

This function removes the Calendar and Meta widgets. You’re adding it to the widgets_
init hook with add_action().

One more thing. Perhaps you’re building a site using a child theme, but said child theme
doesn’t need all the widget areas of the parent theme. Luckily, you can unregister them, as
follows, also in functions.php:

function smashing_remove_some_sidebars(){
unregister_sidebar( 'name-of-sidebar' );
unregister_sidebar( 'name-of-another-sidebar' );
}
add_action( 'widgets_init', 'smashing_remove_some_sidebars', 11 );

Handy tools all. You can read more about these things in the WordPress Codex
(http://codex.wordpress.org).

DON'T FORGET THE THEME CUSTOMIZER
The Theme Customizer is a pretty handy tool to point your clients to when delivering a
theme. It gives the user a live preview of changed settings, such as how different titles and
especially taglines work and how various backgrounds work. It also enables the end user to
try different menus and change to a static front page without having to enter the Settings
pages in the admin interface. Figure 9-1 shows the Theme Customizer with the options
enabled by the Twenty Fourteen theme.
Free download pdf