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

Early return filter #36

Closed webmandesign closed 9 years ago

webmandesign commented 9 years ago

Hi Philip,

Great plugin indeed, thank you for that! :+1:

I have one "issue" though. I would like to add a blog page subtitle (for get_option( 'page_for_posts' ) page) and then display it on theme's frontend. This is not really possible now as when you return the empty subtitle early, there is no filter hook to hook onto.

Can you please consider adding return apply_filters( 'the_subtitle', $title ); to line number 586 of class-subltitle.php file maybe?

Thank you!

Oliver

philiparthurmoore commented 9 years ago

Hi Oliver,

This makes sense. I assume that you've solved this issue by modifying the code on your end? I'm going to leave this Issue open and patch the plugin. It's a good suggestion.

Cheers!

webmandesign commented 9 years ago

Hi Philip,

I'm ashamed as I haven't tried it before. I've done it now and it doesn't work actually. I will do some editing and will let you know about the best solution I've come up with in a while ;)

Regards,

Oliver

philiparthurmoore commented 9 years ago

Sounds good Oliver. When I have some time I'll do some testing on my end as well. I hope to have some time for the plugin this weekend. Cheers.

webmandesign commented 9 years ago

Hi Philip,

I have done some test and it would be actually too complicated to add this functionality into your plugin I guess. I wasn't able to come up with a good solution via changing the code in the plugin. The thing is that the $post variable is being taken from the first post in the loop. This would then determinate when the plugin return early (depending on whether the first loop post has subtitle set up).

And as you might noticed already, the page_for_posts heading would be displayed outside the main loop anyway, so the plugin would return early.

But there is a very easy simple solution for this that your plugin already offer. And simplest solutions are the best ;) So, I ended up adding the subtitle to a blog page title with your get_the_subtitle( $page_for_posts ) function. Something like this:

// This is page title outside the main loop
if ( is_home() ) {
 $title .= ' <span class="entry-subtitle">' . get_the_subtitle( absint( get_option( 'page_for_posts' ) ) ) . '</span>';
}

So, thank you for help, but the issue is resolved and I think there is no need to change the plugin for this ;)

Regards,

Oliver

philiparthurmoore commented 9 years ago

Awesome Oliver! That's a perfectly fine solution that you've proposed. I like it. :) Thanks for letting me know.

philiparthurmoore commented 9 years ago

I should have thought of that also. :-P