Showing posts with label WordPress. Show all posts
Showing posts with label WordPress. Show all posts

Monday, March 14, 2011

Adding WP-PostRatings to Thematic by creating a Child Template (WordPress)

As my previous post says, I wanted to add the WP-PostRatings plug-in to all posts in a Thematic theme. Later I found out that the recommended way of doing this is through WordPress Child themes.
So I read in this aricle the basics of how to create and customize a child template.
Basically the steps to include the plug-in are the following:
  • You start with an untouched Thematic theme
  • Go to wp-content/themes/thematic/
  • Move the thematicsamplechildtheme folder one level up (to wp-content/themes/) and rename it by preference. You just created your new Child Theme.
  • You may modify the template's name by editing the style.css file's first few lines.
  • To add the previously installed WP-PostRatings plug-in to the theme, edit the functions.php file and add the following to the file's end. I copied the function from the parnet theme's content-extensions.php file.
post_type == 'page') {
         $postheader = thematic_postheader_posttitle();        
     } else {
         $postheader = thematic_postheader_posttitle() . thematic_postheader_postmeta();    
     }
     
     echo apply_filters( 'thematic_postheader', $postheader ); // Filter to override default post header
    if(function_exists('the_ratings')) { the_ratings(); } // This command will actually insert the ratings in each post.
}
?>

Enjoy your new theme and I wish you high ratings! :-)

The WP-PostRatings plug-in and the Thematic theme (WordPress)

A few weeks ago I started playing with WordPress because I want to make a personal blog & portfolio website for my girlfriend.
The Thematic theme seems to fit my needs because it's very clean and minimalist. I also found the WP-PostRatings plug-in very nice and easy to use - unfortunately there is not much detail how to make the plug-in appear for each post by default. For someone who is not a (php) programmer this can be quite a challenge.

So, to make the little stars appear below each post's title:
UPDATE: Later I found out that messing with the original theme files is not recommended. Instead, creating a child theme is the preferred way of doing this. I noted the steps in my next post.
Edit the /wp-content/themes/thematic/library/extensions/content-extensions.php file
Find the definition of the thematic_postheader() function
paste the following line after the echo apply_filters(...) command:

if(function_exists('the_ratings')) { the_ratings(); }



















For the record, I was using:

  • WordPress 3.1
  • Thematic v0.9.7.7
  • WP-PostRatings v1.61
I think the approach will be similar for the WP-PostViews plug-in.