How To Enhance WP-theme Autofocus+ V2.0

As you can see on the front­page, I am using Aut­o­fo­cus+ Pro for this blog.

This fan­tas­tic theme has just been updated to V 2.0. This is not a minor update, because AF II (Pro) does not rely on the Thematic-framework any­more. And it comes with a sam­ple child-theme, which I highly rec­om­mend to use!!

Why? Because a the genious con­cept of child-themes lets you pimp, hack, enhance your theme, with­out los­ing all your cus­tomiza­tions in case of an update. Also there are only a few files you have to take care of. Well, actu­ally it can become many — depend­ing on your creativity…

All you have to do is upload the child-theme to a sep­a­rate folder along with the main theme of Aut­o­fo­cus  and acti­vate it — yes, the child, not Big Mama!!

Any­thing you want to change goes into that folder: func­tions, css, tem­plates… whatever.

Once the child-theme is acti­vated, mother will always look what her child has to say about it before she feeds any­thing to the WordPress-loop.

When I first used AF Pro, I imme­di­ately stum­bled into a prob­lem. Fear not, it can be solved eas­ily. The old hack for for­mer ver­sions, that I explained a year ago, does not work any­more, so here is the new way to do it.

The theme has a cou­ple of options. One of them is that you can define a cat­e­gory and a tem­plate for a blog page. But: You can only pick just one cat­e­gory in the theme-options which is used for this spe­cial page. If you want to use the blog-template for another page which only holds arti­cles with a dif­fer­ent cat­e­gory — in my case the KnowHow-page — you are stuck.

So what to do?

You could ask the author of the theme for help. Pro or not Pro-version (paid or not paid), he will point you to — yes, right — google, in order to find solu­tions for cre­at­ing your own tem­plates. You can do that of course — or read on…

Yeah ‚theres tons of expla­na­tions for that.Try googling it.

— Allan Cole

I solved the prob­lem myself the fol­low­ing way.

I copied the file blog-page.php from the theme. Best is to down­load it with a ftp-client (I use the client inte­grated in Total­com­man­der) to a folder on your HD. Then copy it twice (or more, depends on how many sub-sections you want to have blog-wise!) and give the files mean­ing­ful names. For exam­ple, if the blog-page you are going to use it for, is called “Design”, name it design-template.php.

Edit the renamed file with an edi­tor of your choice (I rec­om­mend notepad++) and change the name of the tem­plate in line 3 to Design Tem­plate (or what­ever you want it to be).

Exam­ple:
/**
* Template Name: AF+ Blog Template - pimped by mic
*
* A custom page template without sidebar.
*
* The "Template Name:" bit above allows this to be selectable
* from a dropdown menu on the edit page screen.
*
* @package WordPress
* @subpackage AutoFocus_Two
* @since AutoFocus 2.0
*/

get_header(); ?>

!! If you miss this step, the tem­plate will never appear in the dropdown-menu for tem­plates on the right when you cre­ate a new page or change the prop­er­ties of an exist­ing one.
It is a merely inter­nal thing though. This has noth­ing to do with the name of the blog-page or –cat­e­gory and will not appear any­where on the pub­lic part of your blog.

Next we look for a line that looks like this:

$af_blog_catid = of_get_option( $shortname . '_blog_cat' );

and change it to (for example):

$af_blog_catid = 19;

!! whereas 19 is the ID of the cat­e­gory I use for the given page (KnowHow).
For you the num­ber may and will dif­fer! This means that you have to cre­ate this cat­e­gory first — or, if it already exists, find out its ID.
You can see the ID (the num­ber) in the bot­tom left cor­ner of your browser, when you hover the cat­e­gory in the category-menu (BTW: This is use­ful for many purposes!).

So in my case the com­plete block (here with com­ments for eas­ier under­stand­ing & doc­u­men­taion) looks like this:

// Start the loop for the Blog Category
global $paged, $more, $shortname;
$more = 0;
/* the original line with parsing cat_id from theme-options - hack below */
/* $af_blog_catid = of_get_option( $shortname . '_blog_cat' ); */
$af_blog_catid = 1; /*this is the "General" category on my blog*/

Wipe the sweat from your fore­head, get a drink. Your’re almost done ;)

Upload the new template(s) to the child-theme-directory on your webspace.

Then you cre­ate the new page called Design (or what­ever) and attach the appro­pri­ate tem­plate (e.g. design-template) to it by using Edit/Quickedit from the property-section of “Pages”.

On the page you’ve now cre­ated and mar­ried with the hacked tem­plate from above, only arti­cles with the defined category-ID (19 in this exam­ple) will appear.

Nifty ;)

And in case you want to cre­ate another page for another cat­e­gory of arti­cles sim­ply repeat the same steps (down­load, copy, rename, find out the category-ID, edit, upload, assign tem­plate to new page …) and you’re done.

Oh, and this should work as well for the free ver­sion of the autofocus+-theme. I guess. Did not check though. But I can’t see why it shouldn’t ;)

If have any ques­tions, feel free to ask.

One Trackback

  1. By Enhance WP-theme Autofocus+ | GrainWorks 31 Jul ’11 at 14:14

Leave a Reply

Your email address will not be published.
Required fields are marked:*

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>