0

When adding an ampersand (&) to the Text Widget title, the title breaks at the ampersand position (frontend). So: 'me, myself & I' becomes: 'me, myself ' The ampersand is being stored (correctly) as & in the DB.

What really gets me is the fact that the title is already broken in the output method of the widget (public function widget($args, $instance) { ... ) $instance['title'] is 'me, myself '

Further more, the title is correct / complete on the backend (widget edit page).

Any help would be much appreciated!!

  • 1
    Have you escaped esc_attr( $title ) before saving? – Samuel Elh Jul 11 '16 at 8:33
  • 1
    This used to be a bug in WP pre 3.0 version. I cannot reproduce it with the standard Text Widget in WP 4.5. So you may have a plugin installed that does unwise things with widget titles. – cjbj Jul 11 '16 at 8:38
  • 1
    Please add your solution as an answer and accept it. Else this question weill keep popping up as "unsolved". – cjbj Jul 11 '16 at 9:07
1

SOLUTION: So, it turned out (of course) I myself was causing the problem (...) I am getting the widgets with the 'the_widget()' method and sending the instance params along as I go. The params are query-string-style parameters and are of course 'glued' together with ampersands. Now , I wasn't encoding the individual params so the query string was looking like this: '&title=me myself & I&url=...' This was (of course) messing things up!

Took me long enough to figure out, so I hope this helps others when running into similar issues!

Thanx for your help!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.