Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #9841
    SteveW
    Member

    Hello!

    I have this piece of PHP code which I am trying to insert just above the header:

    <?php
      if (is_user_logged_in()) {
        global $current_user;
        get_currentuserinfo();
        echo ‘Welcome ‘ . $current_user->display_name;
      } else {
    	echo ‘Welcome Guest!‘ "<a href='page_id=43'>Login or register to buy credits.</a>";
    }	  
    ?>

    I have tried inserting it into various places in the header.php file and every time it gives me a HTTP500 error. I’m not exactly sure why, so I was looking for advice on where I should put it so that it either appears just above the entire header (to the right, which I can do with CSS) or just below the social media buttons.

    Thanks!

    #9852
    SteveW
    Member

    I think I’ve made a major whoopsie somewhere in that code!

    Nevermind 🙂

    #9870
    Sakin
    Keymaster

    @SteveW: Yes for editing any core theme files like header.php you need to first build child theme and then edit header.php in your child theme.

Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘Inserting PHP code above the header’ is closed to new replies.