Skip to content
This repository has been archived by the owner on Dec 17, 2021. It is now read-only.

Output subtitles in Recent Posts widget #22

Closed
jdahdah opened this issue Jul 21, 2014 · 4 comments
Closed

Output subtitles in Recent Posts widget #22

jdahdah opened this issue Jul 21, 2014 · 4 comments

Comments

@jdahdah
Copy link

jdahdah commented Jul 21, 2014

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
Copy link
Member

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
Copy link
Author

jdahdah commented Jul 21, 2014

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
Copy link
Member

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
Copy link
Author

jdahdah commented Jul 21, 2014

Alright, thanks for your help!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants