Support » Plugins » Hacks » How to add codes in function.php?

  • When I started customizing my wordpress, I always used the google search as my first weapon. Every time I found some order to add some codes in my function.php file. I tried several time. But I couldn’t do it. Can any one please please & please tell me how to add a code successfully in my function.php. I’ll be grateful..

Viewing 5 replies - 1 through 5 (of 5 total)
  • I assume you want to edit the functions.php file for your theme?

    There are two ways to do this:

    Go to your WordPress dashboard (
    Navigate to Appearance >> Editor. Choose the theme you want to edit from the dropdown and the file from the right sidebar. (This method will only work if your WordPress files are writeable (


    Use your favourite FTP manager to access the location of your WordPress files. Navigate to wp-content/themes/your-theme.
    Open up the functions.php file and edit to your heart’s content!

    The above methods will only work if your theme includes a functions.php file. If no file exists in the wp-content/themes/your-theme directory, then create it.

    Thanks. Where to find I know, but where to add code in the file? Just give me the example.


    Your functions.php must start with an opening php tag, looks like:


    That’s really the only rule. I just add code underneath any existing code. Things don’t have to be in a particular order.

    You must also not ‘nest’ php tags…. so if you copy/paste code don’t accisdentally put in anotehr opening php tag… like:

    existing code
    new code you pasted

    That’s about all the generic help I can give… what specific trouble are you having?

    I understand a little bit. Now I am specifically telling you about my problem Mr. Voodoo-

    I want to put the following code in my function.php

    //hook the administrative header output
    add_action('admin_head', 'my_custom_logo');
    function my_custom_logo() {
    echo '
    <style type="text/css">
    #header-logo { background-image: url('.get_bloginfo('template_directory').'/images/custom-logo.gif) !important; }

    Please show me like you show in your recent post Mr. Voodoo. Thanks..

    [Please post code snippets between backticks or use the code button.]

    You should be able to just paste that code in your themes functions.php file.

    Does it already have an existing functions.php file in it?

    You can paste it right at the bottom.

    If you have a closing php tag, it goes above that

    existing code
    your new code

    If it does not have a closing php tag, that is fine as well. They are not needed there, I never have one

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How to add codes in function.php?’ is closed to new replies.