[wp-hackers] is it possible to change the_title halfway into the processing of a page/post?
halukkaramete at gmail.com
Thu Feb 23 15:42:00 UTC 2012
I will consider your valuable ideas... but I was still wondering
what would be a problem if we'd go with an "ob_start" implementation,
that is straight forward.
Here is one plan...
Create a a plugin ( that hooks to the init ) whose job is to detect if
the page url contains one of those querystring variables that my
If the url is such, then the plugin runs the ob_start. ( Now we know,
we can have control over the_title whenever we want to. )
With that in mind, in the the_content, we use exec_php to do whatever
we want to do, that is contacting the db's getting the current title
for that recid and so on. Obviously, all this code is stored in the
wp_posts and therefore, theme independent.
And then we take an advantage the fact that the ob_start is on and
therefore, we use the ob_get_contents(), do a replacement on the
already computed html and page title, and finally use ob_end_flush()
to seal the deal.
Could you comment what the issues would be with this approach?
On Thu, Feb 23, 2012 at 7:20 AM, Jeremy Clarke <jer at simianuprising.com> wrote:
> On Wed, Feb 22, 2012 at 3:47 PM, Mike Little <wordpress at zed1.com> wrote:
>> add a hook for 'the_content', that calls your display functions.
>> That way, any theme that calls the_content on your page will be get your
>> display output.
> I have a feeling for this use-case a [shortcode] would work better. Indeed
> all the logic should be in a plugin rather than the theme, but define a
> shortcode instead of filtering all the_content, so that it only applies to
> pages where you actually want it (likely a single page).
> Jeremy Clarke • jeremyclarke.org
> Code and Design • globalvoicesonline.org
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
More information about the wp-hackers