First, let me say that the Genesis Featured Posts widget is a wonderfully easy way to easily add customized content to a widgeted area. And, Nick’s Genesis Featured Widget Amplified extends functionality greatly, including the option to automatically shorten post titles to a specific number of characters. However, sometimes shortening post titles automatically can result in words less meaningful than you would like. The following functions allow you to limit the post title length on a widget to widget basis, but replace the title with a custom field. To use these, you simply need to create a post with a custom field called
child_home_title
and then put anything other than 0
in the title character limit field of the widget.
/** * Custom Widget Titles for Home * * @author Jen Baumann * @link http://dreamwhisperdesigns.com/?p=1005 */ remove_action( 'gfwa_before_post_content', 'gfwa_do_post_title', 10, 1 ); add_action( 'gfwa_before_post_content', 'custom_gfwa_do_post_title', 10, 1 ); function custom_gfwa_do_post_title( $instance ) { $link = $instance['link_title_field'] && genesis_get_custom_field( $instance['link_title_field']) ? genesis_get_custom_field( $instance['link_title_field']) : get_permalink(); $wrap_open = $instance['link_title'] == 1 ? sprintf( '<a href="%s" title="%s">', $link, the_title_attribute( 'echo=0' ) ) : ''; $wrap_close = $instance['link_title'] == 1 ? '</a>' : ''; if ( !empty( $instance['show_title'] ) && !empty( $instance['title_limit'] ) ) printf( '<h2>%s%s%s%s</h2>', $wrap_open, genesis_get_custom_field( 'child_home_title' ), $instance['title_cutoff'], $wrap_close ); elseif ( !empty( $instance['show_title'] ) ) printf( '<h2>%s%s%s</h2>', $wrap_open, the_title_attribute( 'echo=0' ), $wrap_close ); }
You should add this anywhere after this line: require_once(TEMPLATEPATH.'/lib/init.php');
but before the final ?>
tag at the end of the file.
The post Genesis Custom Widget Post Titles appeared first on Dream Whisper Designs.