[wp-testers] Re: wp-testers Digest, Vol 31, Issue 2

Travis Snoozy ai2097 at users.sourceforge.net
Sun Sep 2 19:25:10 GMT 2007


On Sun, 2 Sep 2007 18:16:44 +0200, Yazerty <yazerty at yazerty.net> wrote:

> Hello,
> 
> I'm using the get_the_title function in a personnal php script. I
> absolutly need it.
> If this is better to filtered it, ok, but I need to use title in my
> php script.
> Will it change the way I have to use get_the_title according to
> you :-? Thanks !
> 

It depends, but assuming you correctly coded the original script with
the understanding that what you got back was a raw title, probably
yes.

Keep in mind that the "cooked" title (2.3+) is:

* HTML-escaped
* Possibly mangled by filters (e.g., "Some Title" could become "Author
-- Some Title")

If you can NOT deal with mangling (aside from the "Protected: " and
"Private: " mangling that get_the_title does internally), you'll need
to use get_post() or the global $post, and read the post_title
property. All of the rest of your code (which should be HTML-escaping
the title as required) should continue to work exactly as it did before.

If you CAN deal with the mangling, then keep the calls to
get_the_title, but remove any HTML escaping you performed on the title
(e.g., with htmlspecialchars() or htmlentities()). If you need the
title to be unescaped somewhere (i.e., to put it directly into a page
so that the HTML is interpreted), you'll have to use a method like
html_entity_decode().


-- 
Travis


More information about the wp-testers mailing list