wecobble / Subtitles

Add subtitles into your WordPress posts, pages, custom post types, and themes. No coding required. Simply activate Subtitles and you're ready to go.
http://wordpress.org/plugins/subtitles/
GNU General Public License v2.0
117 stars 186 forks source link

Output subtitles in Recent Posts widget #22

Closed jdahdah closed 10 years ago

jdahdah commented 10 years ago

Subtitles are currently not displayed in the default Recent Posts widget. Is there a way to do this in my theme's functions.php?

philiparthurmoore commented 10 years ago

You could try something like the following but you may end up seeing subtitles in places that you don't want them to show up:

/**
 * Display subtitles in recent posts widget.
 */
function theme_slug_subtitle_view_supported() {
    return true;
}
add_filter( 'subtitle_view_supported', 'theme_slug_subtitle_view_supported' );

The issue is that the plugin relies on filtering the_title but only within The Loop. What the above code does is just return the post subtitle for every post title that's shown on a page, no matter where it's displayed.

jdahdah commented 10 years ago

Thanks for responding so quickly! You're right, it works, but it does appear in places it shouldn't, like in the document <title> tag. I've gone with what is probably the least elegant solution: copied the whole WP_Widget_Recent_Posts class into my theme, registered it as a new widget and modified it to include the subtitle.

philiparthurmoore commented 10 years ago

Sounds good. That sounds like a pain, though, but I just don't see any other way around it. I'll update this ticket in the future if I run into any elegant solutions that you may be able to use. Cheers.

jdahdah commented 10 years ago

Alright, thanks for your help!