[wp-hackers] is it possible to change the_title halfway into the processing of a page/post?

Haluk Karamete halukkaramete at gmail.com
Wed Feb 22 02:54:42 UTC 2012


It won't help in this particular case.

if a page url is like this

.com/permalink/page

I want to have some db activity in ( where the the_content) is outputted.

Basically, that section will check if querystring variables
"recid_from" and "recid_to" are passed in the querystring; so if the
url is as follows

.com/permalink/page?recid_from=10&recid_to=20

It will go ahead and look up those records in some custom table and
display it where the_content() would normally be outputted

generated links there could be as follows;

<a href='...com/permalink/page?recid=10'>title 10</a>
<a href='...com/permalink/page?recid=11'>title 11</a>
<a href='...com/permalink/page?recid=12'>title 12</a>
...

And as the user clicks on one of those links, again the same page will
reload and this time a detailed view will be brought up of that
specific record.

In that case, if the url is as follows;

...com/permalink/page?recid=10

the_content will be querying that database table for recid 10 and display it.

That's where the need comes to display the title accordingly.

Since all this time we are in this url > .com/permalink/page

the title is whatever the "page" title is wp_posts

but in this particular situation, that title is only good when no
querystring is attached to it.

as soon as recid this, recid that is accompanied that url, i want
different titles to be displayed not only at html title but also in
page titles.

I'm working on a proof of concept, this is not a real app or need per se.

As to the google, google would never punish you for having different
titles when the url is different.

The only way I can think of this being possible is thru ob_buffer.

By the time, the_content kicks in ( the title has long been computed
by wp ) and there is no hook to go back in time and change it.






On Tue, Feb 21, 2012 at 3:01 PM, Jeremy Clarke <jer at simianuprising.com> wrote:
> On Mon, Feb 13, 2012 at 4:22 PM, Haluk Karamete <halukkaramete at gmail.com>wrote:
>
>> you may find it weird, actually very weird, but is the following possible>
>>
>>
> This is indeed a very strange request.
>
> What you would want to do is use a _GET value in the url in the post
> (href="#?alter_title_for_some_reason=alternate+title"), and check for it
> elsewhere in the code, probably in a callback attached to init like:
>
> add_action('init', 'x_detect_strange_title_altering_link');
>
> In that function you would add a filter to the_title to use the alternate
> text.
>
> Trying to insert the logic to detect the link click inside the post is
> insane. If you are trying to do that you should completely re-assess your
> goals and find a whole new path to achieve them. Ultimately I don't think
> there's a good reason for what you're doing anyway, there should only be
> one TITLE for any given piece of content. Trying to fool Google with
> something like this is more likely to get your pagerank punished than
> rewarded.
>
> --
> Jeremy Clarke • jeremyclarke.org
> Code and Design • globalvoicesonline.org
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers


More information about the wp-hackers mailing list