WP paragraph tags inserted into script

This topic contains 9 replies, has 4 voices, and was last updated by  Kiran 5 years, 1 month ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #470610

    Sam Kneller
    Expired Member
    Post count: 38

    At the top of this page there’s a script in an HTML custom field: https://www.bonjourlafrance.com/travel/france/auvergne-rhone-alpes/voiron/train-stations/gare-de-voiron-train-station/

    The script is not displaying. Apparantly WP has inserted paragraph tags.
    I tried adding a plugin: Raw HTML and some solution here: https://stackoverflow.com/questions/11248628/disable-wordpress-from-adding-p-tags

    Unfortunately I can’t get rid of the <p> </p> tags.
    Any ideas please?
    Much appreciated.

    #470658

    Kor
    Moderator
    Post count: 16516

    Hi Sam,

    Thanks for your reply. Where is it? Could you share some screenshot? Also, share your WP admin access here in private reply.

    Thanks!

    #470659

    Alex Rollin
    Moderator
    Post count: 27815

    Is the script in a GD custom field? something else?

    #470703

    Sam Kneller
    Expired Member
    Post count: 38
    This reply has been marked as private.
    #470718

    Alex Rollin
    Moderator
    Post count: 27815
    This reply has been marked as private.
    #470743

    Kiran
    Moderator
    Post count: 7069

    Hello Sam,

    Try following snippet to prevent custom field html wrap by p tags.

    
    
    function _gd_snippet_output_html_field( $html, $location, $cf ) {
        global $post;
    
        $html_var = $cf['htmlvar_name'];
    
        if ( !empty( $post->post_type ) && ! empty( $post->{$html_var} ) ) {
            $field_title = trim( $cf['site_title'] ) != '' ? __( $cf['site_title'], 'geodirectory' ) . ': ' : '';
    		$field_icon = geodir_field_icon_proccess( $cf );
    
    		if ( strpos( $field_icon, 'http' ) !== false ) {
    			$field_icon_af = '';
    		} elseif ( $field_icon == '' ) {
    			$field_icon_af = '';
    		} else {
    			$field_icon_af = $field_icon;
    			$field_icon = '';
    		}
    
    		$html = '<div class="geodir_more_info  ' . $cf['css_class'] . ' ' . $html_var . '" style="clear:both;"><span class="geodir-i-text" style="' . $field_icon . '">' . $field_icon_af;
    		$html .= $field_title;
    		$html .= '</span>' . $post->{$cf['htmlvar_name']} . '</div>';
        }
    
        return $html;
    }
    add_filter( 'geodir_custom_field_output_html_var_geodir_html_field', '_gd_snippet_output_html_field', 11, 3 );

    Kiran

    #470950

    Sam Kneller
    Expired Member
    Post count: 38

    Kiran,
    Thanks for the reply. Unfortunately, I got this message:

    The code snippet you are trying to save produced a fatal error on line 4:
    syntax error, unexpected ‘&’, expecting ‘]’

    BTW, I added this code to ‘snippets.’ Assume this is correct. Right?
    Sam

    #471649

    Kiran
    Moderator
    Post count: 7069

    Hello Sam,

    I have added snippet and i can’t see such error.

    Please check snippet at Snippets > FIX: WP paragraph tags inserted into script.

    Kiran

    #477637

    Sam Kneller
    Expired Member
    Post count: 38

    Kiran, sorry I didn’t get back to you. Your fix worked perfectly. The script is now running properly.
    A very belated much appreciated.
    Sam

    #477840

    Kiran
    Moderator
    Post count: 7069

    Thanks for letting us know 🙂

Viewing 10 posts - 1 through 10 (of 10 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket