[wp-trac] Re: [WordPress Trac] #1371: Allowing HTML in post titles

WordPress Trac wp-trac at lists.automattic.com
Wed May 30 15:19:02 GMT 2007


#1371: Allowing HTML in post titles
--------------------------------------+-------------------------------------
 Reporter:  MaThIbUs                  |        Owner:  MathiasBynens
     Type:  enhancement               |       Status:  reopened     
 Priority:  lowest                    |    Milestone:               
Component:  Template                  |      Version:  2.1          
 Severity:  minor                     |   Resolution:               
 Keywords:  dev-feedback 2nd-opinion  |  
--------------------------------------+-------------------------------------
Changes (by ManxStef):

  * status:  closed => reopened
  * resolution:  wontfix =>

Comment:

 Post titles aren't meant to have HTML?  Why not?  You are allowed to use
 HTML in each post's body but not its title?  That's rather arbitrarily
 restrictive, don't you think?

 The case for allowing HTML in posts' titles is a strong one.  Primarily,
 allowing a post's title to contain HTML would be very useful and make
 WordPress more flexible.  Why anyone would be against this is beyond me.

 Most uses of the_title() when it comes to markup involve wrapping it in a
 heading element (h1,h2,h3,h4,h5,h6).  According to my reading of the XHTML
 1.0 & 1.1 Specifications there are many valid child elements that are
 allowed inside heading elements, so the potential is definitely there.

 For instance, say you'd like to put emphasis on a particular word in the
 title, what's wrong with using the "em" element?  What about if you're
 talking about say, the C standard library, and your post's title contains
 "{{{#include <stdio.h>}}}" and you'd like to wrap this in a "code"
 element?  What if you wish to wrap a particular part of your title's text
 with a "span" so you can style it separately with CSS? There are many,
 many other perfectly legitimate uses.

 CSS alone cannot give enough control over the styling of a header in many
 cases, the examples I've given show as much, and the fact the the XHTML
 specs allow for child elements inside heading elements shows that they
 realise this, too.

 Of course there are also instances where you then don't want the HTML to
 show up, which is why this patch is necessary.  For instance, Kubrick's
 handling of the title of the hyperlink to each post's title i.e.
 (line 10 of index.php)

 {{{<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent
 Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>}}}

 The "a" element's title parameter will potentially invalidate the entire
 page's code if a post's title currently contains markup.  This is bad.

 Therefore, a cautious "no-HTML by default" approach to the_title() would
 be good and is exactly what this patch would provide, allowing older
 themes to continue to function while providing the means for newer themes
 to take advantage of the extra functionality.

 As such, I'm in STRONGLY in favour of this patch to the_title(), it'd
 definitely help people do perfectly valid things with post titles that
 they currently can't.

-- 
Ticket URL: <http://trac.wordpress.org/ticket/1371#comment:19>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list