• Hi everyone,

    I already asked in the German WP forums, but it seems nobody there can (or wants to) help me. So I’ve come here.

    The problem is indeed very simple, and I really wonder whether I’m the first person to have it or why there is absolutely no information on it available. It’s all about HTML in headings. You can see the problem here:

    http://n.ethz.ch/student/krugs/

    And no, the problem is not that I’m using application/xhtml+xml, it also appears when using text/html, then the page just displays wrong. As you can see, I’ve put a “language tag” in my heading to mark up english text as english. Now WordPress somehow does not remove (or otherwise prepare) this HTML to appear inside the comment link’s title element. And as inside an HTML attribute, no HTML itself is allowed to appear, the parser has a problem.

    Is there a plugin for this problem? I know I could fix it probably within 5 minutes modifying some PHP code, but I don’t want to do that. It just sucks to re-change your code every time a new WP version is out.

    Thanks already for having read all this ;), and I hope maybe someone can even help me.

    Regards,

    Sacha

Viewing 2 replies - 1 through 2 (of 2 total)
  • Basically, wordpress puts anything you put in the post title field into the <title> element. I don’t think there is a way you can stop it from doing that in the options.

    Since <title> can only contain CDATA and not PCDATA, it will be rendered as text in browsers.

    I’m sure if you wrote a plugin it would be extremely helpful for a lot of people, just think of the google hits your site will get!

    I’m pretty sure you could hook it up with the filters that are already in place that take out unwanted HTML from comments.

    Thread Starter silentwarrior

    (@silentwarrior)

    Oh, I’m sorry, that was a misunderstanding – I don’t mean the <title> tag itself, but a) the headings of the respective posts and b) their “#n comments” links, in which as a title attribute (i.e.: <a href="..." TITLE="...">), the heading of the post itself appears. And here lies the problem: If there is HTML in the post heading, it is also put into this attribute, but that is not allowed. WordPress does not filter out HTML here which it actually should do. So I thought there might be a plugin to solve this. (I believe I can remember something like that for WordPress 1.5, although I’m not pretty sure it really did the same. It was called something like “Sanitize titles”. And yes, I know there is a filter/action (?) which is called the same, but it doesn’t do what I want.)

    I have absolutely no problems with <title> itself, and I know from the HTML compendium that it is CDATA only.

    I have also searched the filters and/or actions (don’t really get the difference yet, to be honest) for anything to modify the “#n comments” link, but as “TBD” as the description of most of them is not really useful, I haven’t been able to find anything suitable.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘HTML in headings’ is closed to new replies.