• Hi

    I tried searching for answers on this but I couldn’t find anything; apologies if it has been asked before.

    I’m doing up a small button for each of my posts to allow them to be submitted to Reddit. The code I’m using is this:

    <a href="https://www.reddit.com/submit?url=<?php the_permalink(); ?>&title=<?php the_title_attribute(); ?>">Share on Reddit</a>

    The problem is that I also want my site to validate, and the W3C Validator is throwing an error as a result of my usage of the_title_attribute in the code. The spaces in the title need to be encoded (as “%20” or similar) in order to get the code to validate.

    So, any easy way to get spaces in the_title_attribute to be encoded? Alternatively, is there a better or more appropriate function to use in this context?

    Thanks.

    P.S. I’m running 3.0.3, all up-to-date, but that’s not yet in the version drop-down as an option.

  • The topic ‘the_title_attribute and encoded spaces’ is closed to new replies.