[wp-trac] [WordPress Trac] #42905: add_filter( 'the_title',<func>, 99 ); woudn't fire after add_shortcode

WordPress Trac noreply at wordpress.org
Fri Dec 15 10:05:59 UTC 2017


#42905: add_filter( 'the_title',<func>, 99 ); woudn't fire after add_shortcode
-------------------------------+----------------------
 Reporter:  strech             |       Owner:
     Type:  defect (bug)       |      Status:  closed
 Priority:  normal             |   Milestone:
Component:  Shortcodes         |     Version:  4.9.1
 Severity:  normal             |  Resolution:  invalid
 Keywords:  reporter-feedback  |     Focuses:
-------------------------------+----------------------
Changes (by dd32):

 * status:  new => closed
 * resolution:   => invalid
 * milestone:  Awaiting Review =>


Comment:

 Thanks for confirming @strech

 In this case then, it's working as expected, as `the_title()` has already
 output to the page at the point in time when the content is rendered and
 parsed.
 If you were to change your template to display the title after the content
 of the post, then it'd work as you're hoping.

 Your best bet is to not put the functionality into the shortcode callback,
 and instead process it earlier in the pageload somehow. You could also try
 pre-rendering the content by calling `apply_filters('the_content',
 $post->post_content)` before the title it output, but that'll mean the
 shortcode will run twice.

 I'm closing this as `invalid` as WordPress isn't intended to work in the
 way you're hoping it would. Trac isn't for support questions, but the
 volunteers in the [http://wordpress.org/support/ Support Forums] may be
 able to assist.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/42905#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list