WordPress admin bar blank or not showing

I was modifying a custom wordpress theme earlier, I was logged into WordPress and couldn’t work out why the admin bar, which is meant to show at the very top of your window was not showing / blank. There are two possible reasons why this was happening:

  1. (Most likely) The wp_footer action is not present in your theme
  2. Your user settings have the setting disabled

So if you’re pulling your hair out, I hope this helps!

WordPress fetch feed

A terrific and often under utilized function in WordPress is the fetch_feed() function. Basically it grabs an external feed and parses it using simplePie and feedCache, this is great as it means WordPress has built in functionality to retrieve, handle and cache.

Any website that displays an rss feed can be read, so you could display latest posts, news or even a twitter feed. Here is the Official WordPress documentation for fetch_feed()

I’ve used this function before for a particularly complicated sitemap that was part of the same domain but using a different CMS, using it to display a twitter feed is the obvious possibility for me, but you can literally use it for any feed.

The only tricky part is altering the cache of the results, the code below is used in your functions file to alter the cache transient lifetime (in seconds)

add_filter( 'wp_feed_cache_transient_lifetime',
             create_function('$a', 'return 1800;') );

Multiple Loops in WordPress with SEO in mind

Using multiple loops in a WordPress template can be necessary and confusing.

Let’s say that you want to list your posts on the homepage as per normal, and then also display a list of testimonials for example, somewhere else in the page. You could do something like the following:

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>

  // blah blah content goes here

<?php endwhile; endif; ?>

// Get the last 5 testimonials posts
  <?php query_posts('category_name=testimonials&posts_per_page=5'); ?>

  <?php while (have_posts()) : the_post(); ?>
    // Testimonial posts go here
  <?php endwhile;?>

The problem I’ve encountered from using SEO plugins, such as SEO platinum is that with using the query posts function AFTER your main loop is that it appears to reset the metadata information associated with the main loop and bind it to your secondary loop. For SEO this can be disastrous, title and meta description will be associated with the wrong posts and depending on your template, will be duplicated on most / all of your pages.

From my experience the simplest way to get around this is using the get_posts() function. Using something like the following:

<?php
 global $post;
 $testimonials = get_posts('numberposts=5&category_name=testimonials');
 foreach($testimonials as $post) :
   setup_postdata($post);
 ?>
// echo permalink and title
   <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
 <?php endforeach; ?>

This method works well for me, if anyone else has another way that is better please share.

Installing wordpress

If you’re new to  hosting your own website or have never touched wordpress before then manually installing wordpress may be a little tricky. For those of you who have  never done it, don’t worry because it’s really a easy process. WordPress gives you the ability to blog or use it as a cms, whilst having full control over the design and development of the site.

Here is an easy to manage list on what to do.

  1. Download the wordpress package here
  2. unzip the package
  3. Transfer the wordpress files from your local machine to the server you will be hosting wordpress on, using FTP. Some FTP clients are smartFTP, fileZilla and winSCP, all will do a great job at what we need to do.
  4. Now you must choose where wordpress will be stored. If you want it in the root directory then it is in public_html. If you want it in a sub directory or another folder navigate to that and transfer the files within that directory.  (NB. transfer the files inside the wordpress folder not the “wordpress” folder itself.
  5. It’s at this point whilst the files are transferring that I like to create my database
  6. Create a MySQL database a user and also password for that database
  7. Once the files have been transferred edit the file called wp-config-sample
  8. Where opened, amend the php file to include the name of your database, user and password in the appropriate areas (NB. make sure to wrap them inside single quotes eg ‘password’
  9. Change the file name from wp-config-sample.php to wp-config.php then upload it to your server, or if you edited live leave it on the server.
  10. Once these steps have been completed and you are confident the data is correct you need to run the install wordpress script.
  11. If you have installed wordpress in the root directory then you would navigate to “http://example.com/wp-admin/install.php” with your domain being in place of example.com. If you installed wordpress in another directory then navigate to that address with /wp-admin/install.php after it.
  12. Now you will be prompted to enter your details about your blog and email address
  13. That’s it, wordpress wil be installed and you’re ready to rock and roll!
  14. If wordpress is running fine then there is no need to worry about this next step.
  15. Sometimes you may get a 500 server error, the most common reason for this is in fact that index.php has it’s permissions set to 777 or 775. All you need to do is go into your FTP and select index.php (wherever you installed wordpress) and change the permission to 755. This should fix the problem.
  16. If that is still not solving the issue, check the error log and see what the problem is as sometimes php may not be enabled.

Well that’s my guide, if you have any other queries or suggestions please leave a comment and i’ll get back to you as soon as I can :)