Simplefolio and WordPress 3.1 (3.2.1) fix
GeneralSo recently I upgraded my WordPress installation to WP3.1, however, that broke the slider on my Simplefolio template.
Update July 29, 2011:
I recently upgraded to WordPress 3.2.1, and everything seems to be working properly as expected. Will update if anything breaks.
End of Update
I tried everything from upgrading to the latest bleeding edge, to 3.2 beta, nothing worked, I didn’t want to downgrade to 3.0 simply because I didn’t want the hussle if anything bad were to happen.
Problem:
$my_query = new WP_Query('showposts=10&category_name=portfolio');
This should theoretically return all the posts under the category named “portfolio” but I get all the post returned that is not in the “portfolio” category.
This query is called:
SELECT SQL_CALC_FOUND_ROWS wp_posts.* FROM wp_posts WHERE 1=1 AND ( wp_posts.ID NOT IN ( SELECT object_id FROM wp_term_relationships WHERE term_taxonomy_id IN (5,6,7,45) ) ) AND wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private') GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC LIMIT 0, 10
The “NOT” in the query selects everything but the posts from the portfolio category. Bloody hell! It worked before the 3.1 upgrade.
But fear not! Here is a quick hack so that you can get the scroller back without doing massive irreversible hacks and patches.
Update:
Before you copy the code, make sure you use the proper apostrophes, WordPress displays the “Letter apostrophe” instead of the normal “typewriter apostrophe” Wiki article.
Go to the admin panel->Appearances->Editor->Home Page Template (template-home.php)
Change:
$category = get_option('sf_portfolio_category');
To:
$category = sf_get_category_id(get_option('sf_portfolio_category'));
AND
Change:
$my_query = new WP_Query('showposts='.$slide_count.'&category_name='.$category);
To:
$my_query = new WP_Query('showposts='.$slide_count.'&cat='.$category);
And now the scroller is showing the proper posts.
PS: If you find this post useful, or it has saved you some time, effort or money. Feel free donate a can or two of soup to your local food bank :)
Works great!! Thank you!!
Thank you!
Hi there:
I use this plugin: http://wordpress.org/extend/plugins/wptouch/
Cheers