Archive for the 'tips' Category

WordPress Theme Developers Tip – Automatic Feed Links in 3.0

Thursday, May 20th, 2010

Version 3.0 of WordPress is due out soon, and theme developers are getting geared up to implement the new features. The new menu system has received much attention as it’s one of the biggest changes, besides the merge of the WPMU code, that most users will use.

One feature that I didn’t know exists until now is automatic feed links which will output all the different feed links to current page the users is on to the header. It was added in 2.8 but has been changed how it works for 3.0. For example on a single post page the main blog feed, and the single post comment feed links are added to the header allowing a user to easily subscribe to the either feed. Another is on a category archive page the feed for the main blog, as well as the feed for all posts in that category are added. So I’ve got this feature added to my Techozoic theme but to maintain backwards compatibility I though I would share the simple function I came up with.
(more…)

Tags: , ,

WordPress Theme Developers Tip – Adding Theme Menu

Friday, March 26th, 2010

I’ve already discussed how to add an theme options page. Sometimes, as my theme has, a theme just outgrows having one menu page for everything. Instead of adding a second page under the Appearance Menu a separate menu might be best. The below code is an example of the functions required to use a separate menu.
(more…)

Tags: , ,

WordPress Theme Dev Tip – Dynamic Stylesheets

Friday, September 18th, 2009

WordPressA dynamic stylesheet using php is a powerful thing, when accompanied by a user options page it can really make a theme. I’ve recently done this to my Techozoic theme, and I’m going to share how this works and some time saving tips.

First you’ll want some way of letting the theme user choose what will change in the stylesheet, I explain how to do this with a theme options framework here. After you’ve got all the options set the way you want you need some way of getting those into your theme. At first I was just using <style></style> tags in the header of the theme, while this works it just isn’t an efficient way of writing a theme. What I wanted to do was have an external file that changed with the options but that could also be cached by the web browser, to improve performance, save bandwidth and overall have a better written theme.

Now if your using a framework similar to mine or your using mine then you know you have to pull some info from the WordPress database to fill in your variables from your option page. This posed the biggest problem because since this was an external page none of the WordPress functions would work. To get around this in the first version I just loaded the wp-config.php and wp-load.php files in the top of the file. This is bad practice because WordPress site owners can move these files around now and there is now way to know where to load these from. So I spotted the solution from another theme developer. Making an array of all the option values then using php GET variable on the external stylesheet. Now onto the actual code.

(more…)

Tags: , ,

Dynamic Stylesheets using PHP

Thursday, September 17th, 2009

CSS Recently while doing some work on my theme for WordPress I came across a very helpful idea. Using PHP in a stylesheet to make it more dynamic. The basic idea is to use PHP variables and define certain elements that repeat in various places such as a color code to make it easily changeable by only having to change one line instead of searching for and replacing multiple times. Other examples are fonts, images, widths, even whole sections of code could be shown or hidden with the use of variables and an if statement.

(more…)

Tags: , , ,

Making Header Image Clickable Link

Monday, November 3rd, 2008

CSSSometimes a text header link just doesn’t cut it. Making a image a clickable header link is very simple. You can see the result above, the area around the name in the image is a link back to the home page.

(more…)

Tags: , , ,