Did you ever needed to change the category in the permalink. If you have say a post in two category and you have a permalink structure /%category%/%postname%/ Then the wordpress by default chooses the lowest id category for your posts permalink but with this plugin you can change it to the desired category. It was really helpful for me. you can try this.
Plugin url: http://wordpress.org/extend/plugins/hikari-category-permalink/
There is changes in wordpress wp_capabilities meta field for users in wordpress 3.0, I noticed it when i had to list authors of the site.
For author the wp_capability meta field was
a:1:{s:6:"author";b:1;}
New one is
a:1:{s:6:"author";s:1:"1";}
So to list new authors you will have to check the users capability against the new one.
In recent one of my project i had to use single template according to the category the post is in. It also checks parent category it is in to select desired template. I tried following and it worked perfectly. you have to make new template with single-categoryname.php
add_filter('single_template', 'wpexpo_single_template');
function wpexpo_single_template($t)
{
foreach( (array) get_the_category() as $cat ) {
if ( file_exists(TEMPLATEPATH . "/single-{$cat->slug}.php") ) {
return TEMPLATEPATH . "/single-{$cat->slug}.php";
}
if($cat->category_parent!=0){
$parent_cat = get_category($cat->category_parent);
if(file_exists(TEMPLATEPATH . "/single-{$parent_cat->slug}.php")) {
return TEMPLATEPATH . "/single-{$parent_cat->slug}.php";
}
}
}
return $t;
}
Have you ever tried of using parent category template to the sub categories. Here is a way to do it. Use the following code below to your functions.php file and you can use parent category template to subcategories.
For example you have category template file category-category-slug.php and we have a sub category of category-slug then all subcategory of category-slug will use this template if they don’t find their own template.
Continue reading →
Today i was coding a theme and i needed to get the current page’s slug so here is the code that we can use to get the page’s slug.
$post_obj = $wp_query->get_queried_object();
$slug = $post_obj->post_name;
Posted in tutorial
|
Tagged page
|
Here are some excerpt filter for wordpress that i find useful. This codes go in to your theme functions.php file
1. If you need to remove unwanted tags <p> from the the_excerpt()
remove_filter('the_excerpt', 'wpautop');
Continue reading →
Posted in tutorial
|
Tagged excerpts
|
You might have used post thumbnail featured that came with wordpress 2.9.2. Well I use it a lot in many of my projects. So you might want to get the thumbnail size resized to say some fixed width and height. You can use following code for it.
you can enable post thumbnail with following code in your theme functions.php file.
add_theme_support('post-thumbnails');
Continue reading →
Posted in tutorial
|
Tagged post thumbnail
|