• Objective: Wrap <span> tags around first word of blog title.

    Status: Successfully hard coded header.php so that it wraps <span> tags around first word and assigning the string to $new_title.

    Problem: How to replace bloginfo(‘name’) with $new_title.

    Is there a better way to approach this like creating a function that allows the blog title with HTML tags? Is there a trick in using HTML tags with the blog title?

    Where to go from here?

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    The issue is any less than and greater than signs seem to get translated to HTML entities like ampersand+lt; (can’t seem to construct a proper entity without it getting converted) every time the data passes through any function, so the solution will change depending on where the data goes.

    For the blog title, it also depends on the theme. Most themes use bloginfo('name') which does attempt to create HTML entities. You can substitute in echo get_option('blogname'); which does not attempt to convert to entities.

    That’s not the entire solution. Entities are also created when you save the value entered in general settings. The way around that is to hook the filter ‘pre_update_option_blogname’ and apply html_entity_decode() to the passed value before returning it. This undoes the entity conversion that was applied to the value before it is saved to the DB.

    Once you circumvent the entities in both places, it should be possible to enter HTML along with the title text and it will survive as HTML when finally output.

Viewing 1 replies (of 1 total)
  • The topic ‘Make bloginfo('name') HTML friendly’ is closed to new replies.