yootheme wordpress layout override

Recently working on a clients website i needed a different styled layout for one category.

Usually in Wordpress this can be easily accomplished by copying your archive/content/single (here just showing for a category) php file and rename it with the name prefix so category- followed by the ID or slug.

category-{id}.php
category-{slug}.php

So if you want custom layout for a category with the slug "Fun". Download the category.php file from your theme folder and re-name it category-fun.php then make your changes and upload.

Yootheme templates don't play too well with this.

Now I'm sure there are heaps of better way to accomplish this but this is what i did. I wanted to keep the same override process. so adding a prefix (slug) to the  _post.php  (e.g. _post-fun.php ) file would then output a different layout.

in wp-content/themes/[yourThemeName]/warp/systems/wordpress/layouts/_posts.php just under line 16 i added:

//get the category slug
global $wp_query;
$queried_object = $wp_query->get_queried_object();
$slug = $queried_object->slug;   

then i replaced

$columns[$column] .= $this->render('_post');

With

//see if we have a file for an override
if ($this["path"]->path("layouts:_post-".$slug.".php")) {
    $columns[$column] .= $this->render('_post-'.$slug);
}else{
    $columns[$column] .= $this->render('_post');
}

and then uploaded my new _post-fun.php file, modified to suit my new layout.

So now my category "fun" has it own fun (terrible terrible pun i know) layout.

You may be interested in...



Had enough browsing?

Get in touch

Get in touch

We wont charge you for the inital project meeting. So really you have nothing to lose.

Fill out the form below with as much information as you can provide and we will be in touch with you asap to discuss.

Name(*)
Please type your full name. Also only allowing alpha numeric characters here. Why do you have all this fancy stuff in your name anyway?

Email(*)
Invalid email address.

Phone
Please enter a valid phone number.

Enquiry Type(*)
Invalid Input

Message(*)
Please only use alphanumeric characters in your message

Invalid Input