Skip to content

Instantly share code, notes, and snippets.

@seoagentur-hamburg
Last active August 10, 2016 17:39
Show Gist options
  • Save seoagentur-hamburg/12b3a514fc1decdb804b387b0026a1f7 to your computer and use it in GitHub Desktop.
Save seoagentur-hamburg/12b3a514fc1decdb804b387b0026a1f7 to your computer and use it in GitHub Desktop.
<?php
// Ab hier kopieren
// Füge Deinen Code genau zwischen <script> und </script> ein. Er sollte im Anschluss wie folgt aussehen:
function google_custom_search_tb( $atts ) {
return "
<div class=\"searchresultscontainer gcs\">
<h2>Deine Suchergebnisse für: <mark>".htmlentities($_GET['q'])."</mark></h2>
<script>
(function() {
var cx = '001086175777875378546:mznt3glqa3i';
var gcse = document.createElement('script');
gcse.type = 'text/javascript';
gcse.async = true;
gcse.src = 'https://cse.google.com/cse.js?cx=' + cx;
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(gcse, s);
})();
</script>
<gcse:searchresults-only></gcse:searchresults-only>
</div>
";
}
add_shortcode('google_custom_search_tb', 'google_custom_search_tb');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment