0

I would like to paste my Google Custom Site Search code into the editor to appear on one of my pages.

It works when pasting into the "text" side, but get's turned into a NBSP if I flick to "visual"

Is there a way I can keep <gcse:searchbox-only></gcse:searchbox-only> in tact in the editor?

3

I would suggest a shortcode:

function gcse_wpse_143459($atts,$content) {
  return '<gcse:searchbox-only></gcse:searchbox-only>';
}
add_shortcode('gcse','gcse_wpse_143459');

Then use [gcse] instead of trying to paste in an oddball html-ish tag.

2
  • this would be really helpful for me but where exactly do you insert the shortcode? I am a novice so don't know if it goes before <script>// or after or elsewhere ? Thanks – From the Poolside May 17 '14 at 13:32
  • 1
    @Stephanie Not 100% certain what you mean, but to clarify, the code s_ha_dum suggested goes to the functions.php - for example, could be in a plugin too - and then you can use the shortcode [gcse] in the editor. – Nicolai May 17 '14 at 13:47

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.