WordPress: How To Make Sidebar Load Last
A big problem for me is using Wordpress templates with the sidebars on the left side. Oftentimes, the left sidebar loads before the main content of my blogs. This is extremely annoying. If, for some reason, my buttons, badges, or blogrolls in my sidebar are taking too long (which usually happens), the main content will never load!
Here’s a little tweak I have learned to force the main content of the blog to load before the sidebar. Please be aware that NOT all themes are alike, so your experience may vary. ALWAYS BACK UP YOUR BLOG before changing the coding. You should always back up your blog, anyway! But if you are going to attempt to do my fix, please back it up. Rest assured, this fix is simple and quick and painless. But you should always back up your existing information, just in case.
Notice in your Wordpress php files that you have varying files, like footer.php, index.php, single.php, and etc. My own theme had the basic php files without any extras. Some more complex themes may have additional php files to do the jobs that your theme requires. You may have to play everything by ear, here. The nice thing is that my fix does not delete anything or alter anything major: all it does is tell the computer what part of the theme to load first.
OK, enough of all the preliminaries. In my theme, these are the php files that we’re going to alter. We’ll go over them individually.
index.php
page.php
single.php
The index.php is the information for the “face” (or homepage) of your blog. It tells the blog how to operate and when. Open the file now. You’ll see a lot of coding. What concerns us is the “get header,” “get sidebar,” and “get footer” stuff at the very top and the very bottom. So at the top, you’ll see this:
<?php get_header(); ?>
<?php get_sidebar(); ?>
<div id=”content”>
then you’ll see a lot of coding after that, and then at the bottom of the file, you’ll see this:
<?php endif; ?>
</div>
<?php get_footer();?>
These two sections are telling the computer to load the main homepage of your blog in this order:
1. Header
2. Sidebar
3. Content
4. Footer
We want to change that. We want to switch the “Sidebar” and “Content.” And that is what you do. Copy this section in that file, that says:
<?php get_sidebar(); ?>
and then delete it. Now, scroll down to the bottom of the file. See where the file says:
</div>
<?php get_footer();?>
Place your copied “get sidebar” code right before the “get footer” code. You may have to make a new line (by pressing ENTER on your keyboard) if there is no space. I did have to.
So now, the very top of this index.php file says:
<?php get_header(); ?>
<div id=”content”>
And the very bottom of it now says:
</div>
<?php get_sidebar(); ?>
<?php get_footer();?>
Save the document and upload it to your FTP or, if you are working within Wordpress in your browser, press SAVE.
You have to go back and do this same thing for each of the other php files I listed: the single.php, page.php. Some themes have archives.php, and different templates for different Pages on their blogs. If so, just go through those and do the same thing. This will make the loading of your blog consistent, whether people visit your homepage, a single post, an archived post, or a page post.
When you are done and everything is saved, your blog should now load in this order:
1. Header
2. Content
3. Sidebar
4. Footer
Remember, if you find that you don’t like the fix, or something goes screwy, you can always revert back to what you have as your back up. You DID back up your blog, right?
If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.











This is great. I found your blog yesterday and have been reading non-stop. In fact, i have liked your blog so much i nominated you for the “I Love You Blog” award on my blog.