why is the <?php wp_head ?> tag creating a top margin at the top of my theme header

Hey people, I've been coming here for a while but just decided to join.

I'm new to php and I'm trying to make a website with WordPress as the CMS.

Anyway, I'm basically making my own theme because I don't want my website to look like a blog, and it's going pretty smoothly so far but theres this huge top margin gap in the browser even when I set margins to 0px.

I tried trial and error and found out that it's being caused by: <?php wp_head(); ?>


It's two different things.

1. wp_head() function

wp_head() is a template tag to print whatever plugin / theme specific function used by wordpress action. Read codex for more detail about it.

2. The admin bar

The top margin, is generated by wordpress's admin bar.

To fix this for logged in users you can do a couple of things:

Disable admin bar from the admin:
  1. Go to admin panel
  2. Users >> User Profile
  3. Uncheck 'when viewing site' on 'Show Admin Bar'
Remove the admin bar from your theme entirely:
  1. Open your functions.php
  2. Add this to it:

    function my_function_admin_bar(){ return false; }
    add_filter( 'show_admin_bar' , 'my_function_admin_bar');
Remove only the code which creates the css:
  1. Open your functions.php
  2. Add this to it:

    function my_filter_head() { remove_action('wp_head', '_admin_bar_bump_cb'); }
    add_action('get_header', 'my_filter_head');

Note: Extensive updates are from @hitautodestruct

Need Your Help

Checking user by his password. PHP MySQL

php html mysql

I tried to write a simple registration and log-in code but I get a problem in the log-in file.

Check if form is called from correct page

php forms

On page1.php I have a form which sends vars via POST to page2.php.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.