Google Custom Search in wordpress page: Can you insert Google Custom Search code-CoursePress page

I am running the CoursePress plugin. I put the Search box code and Results code for Google Custom Search (not the plugin) into two (separate) pages.

The results do not show. Instead, this displays on the results page

"No Courses Found
Sorry, but nothing matched your search terms. Please try again with some different keywords."

The results page has Google's code for displaying its search results. Yet there are no Google search results, and the above message is displayed.

  • Michelle Shull
    • DEV MAN’s Apprentice

    Hiya, BGF!

    I tried to replicate this on my own site with a default theme and the CoursePress theme (see screenshot), and things are working okay. Which theme are you using? Can you briefly switch to a default theme and see if the search page is still giving you the CoursePress message?


  • BGF
    • The Incredible Code Injector

    Changing the theme had no effect.

    In the <form action="/me/search/results/" id="cse-search-box"> Google Custom search form code, what do you have for the ACTION URL?

    Should I have the wp url that shows in the browser for the action/results page? This is what I have

    <form action="/me/search/results/" id="cse-search-box">

  • Michelle Shull
    • DEV MAN’s Apprentice

    Heya BGF!

    This is my form code, I used the direct method, rather than the plugin, but the output should be the same:

    <script>// <![CDATA[
      (function() {
        var cx = 'xxxxxxxxxxxx';
        var gcse = document.createElement('script');
        gcse.type = 'text/javascript';
        gcse.async = true;
        gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +
            '//' + cx;
        var s = document.getElementsByTagName('script')[0];
        s.parentNode.insertBefore(gcse, s);
    // ]]></script>

    I edited out my unique key there, but this is the general idea of what that function should look like.

    Are you seeing something similar in text view of your custom search page?

    One more thing, did you set up a custom search engine (that's just the site you're searching) that you connected?

    Thanks, BGF!

  • BGF
    • The Incredible Code Injector

    Thank you @Ivan Denkov

    What you saw was a temporary results page I made. It is a ColdFusion page outside of the WordPress install.

    Please follow this link to see the results obtained when the results page is a WordPress page.

    I don't know why but the URL variables are treated like they were for a CoursePress course search. More interestingly: have a look at the page /search/resutls/ in wordpress page editor. The Template is "page (without widgets).

    Why is the resulting page showing as a search results page with side widgets?

  • Michelle Shull
    • DEV MAN’s Apprentice

    Hi BGF!

    Sorry for the delay here. I was able to successfully embed the custom search script in a WordPress page in the CoursePress theme, two default WP themes, and our Upfront theme, and it worked each time. I've attached my custom search engine settings in a screenshot below, when you set up your custom search engine, did you grab the code to paste in text view on your custom search page?

    I ask because I do not see that script, or anything like it, in the page source for your linked search page, the one which is only giving you CoursePress results. Sadly, support access has expired, but I want to double check that all your settings on Google's end are correct, and that you've pasted the Google CSE code into your page correctly.

    Thanks, BGF!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.