• Resolved Imagemadhu756

    (@madhu756)


    Hi support,
    I don’t want to use different plugins for header and footer and code snippets plugin.
    Since i am using code snippets plugin, could you please tell me how to add any header or footer code from google and advertisement code using Code Snippets plugin.

    Best regards,
    Prakash

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author ImageShea Bunge

    (@bungeshea)

    Hi Prakash,

    You can add code to the <head> section of your website like this:

    add_action( 'wp_head', function () { ?>
    
    	<!-- header code goes here -->
    
    <?php } );

    You can add code to the footer section (just before the closing </body> tag) like this:

    add_action( 'wp_footer', function () { ?>
    
    	<!-- footer code goes here -->
    
    <?php } );
    Thread Starter Imagemadhu756

    (@madhu756)

    Hi @bungeshea Thank you so much for your help.

    Thread Starter Imagemadhu756

    (@madhu756)

    Hi, Could you please let me know either the below code is correct or not? and which one will be more responsive without any side effect?
    /* Describe what the code snippet does so you can remember later on */
    add_action(‘wp_head’, ‘PiForumHeaderCode’);
    function PiForumHeaderCode(){
    /*My code is here*/

    };

    • This reply was modified 5 years, 5 months ago by Imagemadhu756.
    • This reply was modified 5 years, 5 months ago by Imagemadhu756.
    Plugin Author ImageShea Bunge

    (@bungeshea)

    Not exactly. If you are using a named function, then you shouldn’t have the trailing ; character after the closing }.

    I recommend using anonymous functions, as in my examples, instead of named functions, as they are less prone to errors.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘How to add any header or footer code using code snippets plugin?’ is closed to new replies.