I'm not sure if this is possible with the newer Google AdSense code which has the AdSense server holding all the colour settings etc... via an ad channel, but maybe there's a legacy code that will work.

Publicly released AdSense theme (used by thousands of AdSense publishers) I'd like to add a Custom Google Search box where the template files deal with all settings except the pub-number (added on options page).

I've had the code working for years with Google content ad units and Google search ad units using the old legacy code (users add their pub-number and it works without having to setup an ad in their AdSense control panel, the old legacy code holds all the colour settings etc..., editable via options) and now I'm looking at also adding the newer custom search box I recall receiving an email from Google AdSense one of my sites that does use the old search box code won't work soon.

The problem is the new code looks like this:

<form action="http://www.google.com/cse" id="cse-search-box" target="_blank">
    <input type="hidden" name="cx" value="partner-pub-1234567890:uniquechannel" />
    <input type="hidden" name="ie" value="ISO-8859-1" />
    <input type="text" name="q" size="31" />
    <input type="submit" name="sa" value="Search" />
<script type="text/javascript" src="http://www.google.com/cse/brand?form=cse-search-box&amp;lang=en"></script>

I'm assuming uniquechannel references the ad channel (it's not the actual channel ID, but must be based on it).

I've tried removing the ad channel, but get a bad request.

The closest I can get to what I want is a user creating their own ad like the one above and either pasting the uniquechannel code in an option box, but then it would use whatever colours they selected when they setup the ad not the ones I'd setup to match in with the theme.

I have a feeling there isn't a way around this, but since finding this site I've been really impressed with the code I'm finding here (solved loads of problems I've been stuck on), so worth a try :-).


1 Answer 1


You can improve it, combining Google Search and Wordpress Search. using this simple javascript:

function displaygoogle(checkbox){
        document.getElementById("googlesearchbox").style.display = 'block';
        document.getElementById("wordpresssearchbox").style.display = 'none';
        document.getElementById("googlesearchinput").value = document.getElementById("wordpresssearchinput").value;
        document.getElementById("googlesearchbox").style.display = 'none';
        document.getElementById("wordpresssearchbox").style.display = 'block';
        document.getElementById("wordpresssearchinput").value = document.getElementById("googlesearchinput").value;


see more detail here: http://jaider.net/2011-05-08/how-to-combine-google-wordpress-search/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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