This week’s article is a collection of 5 tips that I use personally on my small portfolio of websites. I’ve got tips on adding a favicon to a theme, using transparent favicons, running php within a widget, adding tabs to an article, and how to fix the admin section if saving doesn’t work.

1) Fixing the admin section

If you cannot save any admin settings, re-arrange windows in the dashboard, tags don’t save, etc. Then the AJAX part of the admin section is probably broken due to some strict security settings defined my your web host. Therefore just create a .htaccess file containing the following code (i.e. /wp-admin/.htaccess), and it should all work.

# Fix Admin Section
<IfModule mod_security.c>
SecFilterInheritance Off
SecFilterEngine Off
SecFilterScanPOST Off
</IfModule>

2) Adding a favicon to a Wordpress template

If you want to add a favicon to a Wordpress template, I suggest keeping the icon with the rest of the graphics in your template directory. Traditionally favicons are kept in the root path of a website, but it doesn’t need to be. All you need to do is add a HTML header to header.php to tell web browsers where to find the icon.

The code snippet needs to go between the head tags in the header file. Note the bloginfo(’template_url’) bit of code. In Wordpress, this retrieves the path of the directory for the currently installed theme. This means you can keep your favicon in your template’s image directory.

<link rel="shortcut icon" href="<?php bloginfo('template_url'); ?>/images/favicon.ico">

3) Transparent favicons

If you use a decent graphics program like PhotoShop or PaintShopPro (using the PNG or GIF optimiser), you can set the background colour of an image to be transparent. As long as you save the image type as PNG or GIF, you can create a transparent favicon using the Dynamic Drive Favicon Generator.

4) Running PHP in a widget

I recently needed to restrict what links I showed on my blog, depending on what page was being selected. For example, I needed to only show some links on the home page and the category pages. I’m a fan of using Widgets for displaying content, and since the links I was working with were within the blogroll, I used the PHP Code Widget.

You add a widget in the usual way, but then you include some PHP in the widget too. Here’s an example of the code I used within the PHP Code Widget.

<ul>
<?php if (is_home() || is_category()) : ?>
<li><a href="http://www.google.com/">Only show this link on homepage or category page</a></li>
<?php endif; ?>
<li><a href="http://www.yahoo.com/">Always show this link</a></li>
</ul>

5) Tabs within posts

Most of my sites are predominantly visited by UK or US visitors. This means my affiliate marketing typically focusses on those two groups as a priority. I wanted to show Amazon books for both US and UK visitors, so that UK visitors could go to Amazon UK, and US visitors could go to Amazon US.

Rather than use complex ip geo-filtering, and rather than make incorrect assumptions on the home country of my visitors, I simply used Wordpress tabs. You can see the Amazon book tabs on DailyEcoTips.com.

Conclusion

I hope you found those tips interesting and helpful. If you have any interesting Wordpress problems, please let me know. I might be able to solve them for you.