Add Google CSE
-
I love the search snippet and how it puts it on the navbar. However I would like to use the “Google Custom Search Engine” there instead.
Google gives a code snippet which works as a widget, but would like to have it in my navbar on the bottom right. Can this be done without using a widget?
-
Why not create a new Widget Area and then reposition it with CSS?
Not sure how to setup the widget so it shows in that location.
I remember a post about placing widgets just about anywhere but cannot find it.
what would be the HOOK to place it as a menu item? or to the bottom right of the nav? I have managed to place it EVERYWHERE except where I want it.
OK got it where I wanted it, but it is overwriting my 2nd line on my tagline. How do I fix that? It also killed my menu.
Here is what I used. SITE LINKadd_filter (‘wp_nav_menu_items’, ‘add_my_widget’);
function add_my_widget() {
if (function_exists(‘dynamic_sidebar’)) {
dynamic_sidebar(‘Extra Widget After Navbar’);
}
}I took it off..
I was suggesting CSS:
.gsc-control-cse { position: absolute; top: 20px; z-index: 500; }OK added the css snippet, now its weird. putting a searchbox on top of the navbar. I added _after as it was placing 2 searchboxes and killing the menu. I have the menu back.
Here is what I have now.add_filter (‘_after_wp_nav_menu_items’, ‘add_my_widget’);
function add_my_widget() {
if (function_exists(‘dynamic_sidebar’)) {
dynamic_sidebar(‘Extra Widget After Navbar’);
}
}Tha looks like code that will place a widget area, but you need to have defined it first. See this snippet for an explanation: http://www.themesandco.com/snippet/add-widget-area-header/
That is where I started. I have tried using a widget which does work with the Google snippet, but I just cannot seem to get it to show where I want it.
Back to the original question: I have a html snip from google, where should I place it using a div and then is there any way to use the SEARCH SNIPPET to add it to my menu?What is the Google code that you are trying to place? Could you paste it here? But use backticks (the code button will insert the character if you don’t have it on your keyboard).
Something happened to my login, it says I don’t exist as “questas_admin” anymore. Anyway I am the same person. That being said, here is the google code I am trying to work.
<script>
(function() {
var cx = ‘000594048061160289773:0fmxn8kcbd4’;
var gcse = document.createElement(‘script’);
gcse.type = ‘text/javascript’;
gcse.async = true;
gcse.src = (document.location.protocol == ‘https:’ ? ‘https:’ : ‘http:’) +
‘//www.google.com/cse/cse.js?cx=’ + cx;
var s = document.getElementsByTagName(‘script’)[0];
s.parentNode.insertBefore(gcse, s);
})();
</script>I figured out my WP login issue. The previous post was from me.
I think that what this article is saying is that you can use the search form snippet, if you create a searchform.php file.
But I cannot make it work π
I also tried adding the script instead of the
get_search_form()function (and buffering it), but I couldn’t get that to work either.Don’t know enough about javascript, I’m afraid.
That’s OK, I appreciate the help, I cannot get it to work either. Time to focus on something else.
Thanks
The topic ‘Add Google CSE’ is closed to new replies.
