Header doesn't execute Visual Composer shortcodes on a generated page

Hello WPMU Developers,

I have a question regarding the generated search page in your plugin.
I have recreated the problem on a test domain: See the button in the header
http://dave.meodemo.nl/ ( This is where the shortcode executes )
http://dave.meodemo.nl/?s=Test ( This is where the shortcode doesn't execute )

The reason I use a generated page is because the results actually show up.
When I select 1 of the other options it gives me the following error in my console:
SyntaxError: expected expression, got '<'

When I look at the script the console points to, it shows that WP added a lot of <p></p>

<p>            <script type="text/javascript">
                google.load( "search", "1", {language : "nl_NL",} );
                google.setOnLoadCallback( function() {
                var customSearchControl = new google.search.CustomSearchControl( "005141383361375372180:pu-wxk5lljg" );</p>
<p>                var options = new google.search.DrawOptions();
<p>                customSearchControl.setResultSetSize( google.search.Search.FILTERED_CSE_RESULTSET );
                customSearchControl.draw( "cgs-cgs-search-form-21", options );</p>
<p>                ///run search by query
<p>                }, true );</p>
<p>            </script></p>

Is there any way to fix this problem?

Thanks in advance

  • Predrag Dubajic

    Hey Joost,

    Hope you're doing well today :slight_smile:

    I did some tests on my installation and the shortcode in header doesn't work on generated page for me as well, however using other options work fine for me without adding additional P tags in the code.

    Could you try switching to default WP theme and see if Standard/Search page option works for you after that so we could see if this is theme related?

    Best regards,

    • Joost

      The other options work on the default WordPress theme.
      They also work on a default Total theme. ( The one I'm using on my sites )
      But on the site where I want the plugin to run, there are added <p></p>.

      Do you know which part possibly causes the added <p></p>?
      I am gonna walk through every plugin one by one to see if it helps any.

      I tried the following, but doesn't work:

      remove_filter( 'the_content', 'wpautop' );
      remove_filter( 'the_excerpt', 'wpautop' );

      I deactivated all the plugins and the problem still occurs.

      Do you have any more ideas?

  • Adam Czajczyk

    Hello Joost!

    Please take a look at "Settings -> Custom Google Search" page an see if the "Embed Code/Search ID" field is a "clear" text box or if it's an "editor" (like WordPress editor) on your site. These paragraph tags being added suggest that the field got somehow "hooked up" to WP editor so it's worth checking.

    If it's not the case can you tell me please what theme are you using on the site in question?

    If it can be freely downloaded from the web (not a premium theme) please point me to the download so I could test it. If it's a premium theme, would you mind granting me a support access to your site so I could take a look at it there? Here's a guide on granting an access:


    Best regards,

  • Adam Czajczyk

    Hello Joost!

    Thanks for granting access. I have just checked your site and reviewed settings in details and I still thing that it's most likely related to the theme or to some specific plugin setting that's processing the content in a way that adds paragraph tags.

    Furthermore, I think that has something to do with "custom post templates" partial template (which I unfortunately am not able to examine via "Appearance -> Editor) and excerpts. As you mentioned that this is working fine on another site with the same theme, would you mind granting me an access to that working site too?

    I'd like to take a look at it too and compare both. Hopefully I would be able to track down the difference between these two setups that's affecting this.

    Best regards,

  • Joost

    Hi Adam,

    Thank you for your reply. I have checked every plugin by turning them off and it still occurred, so I don't think that's where the problem lies. I have granted you access to my other installation where the search results do show up.

    You're pretty on point with the custom post templates. Here's what both sites say for the excerpt.

    // Custom Excerpts
    	if ( $post_excerpt ) :
    						$output = wpautop( do_shortcode( $post_excerpt ) );

    And for the test installation (which has a slightly newer theme version):

    // Custom Excerpts
    	if ( $post_excerpt ) :
    		$output = do_shortcode( $post_excerpt );

    Changing the script to the latter indeed fixes the problem. So I'll be updating the theme in the next days and I'll mark this topic as resolved as soon as it's fixed.

    Thank you for your incredible support. I'm glad you've found it.
    Have a nice day!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.