2,052 days ago | in Community | 4 Comments | Map: Post
Tags: projects, wordpress, work / select all
Hi WordPress Community!
Did you have the same weird feeling by giving up Ultimate Tag Warrior or similar? (btw. thanks Christine for your support and greetz to nz) I was a little bit frustrated, that this great piece of work is not supported in WordPress 2.3…
Anyway, first of all it took a long time to update my theme (especially for the mash-ups). And as only posts are supported for tagging, I also had to integrate the built-in tags feature for pages. Importing them from UTW into the new database structure (taxonomy/terms) worked like a charm. A few days after the new WordPress version was released, I found a plugin on Michele’s blog which adds the necessary where-statement (as well as the tags section in page edit of the WordPress admin menu) for associating pages and not only posts with tags, but I still missed the pages tags in the tag_cloud.
So, the final piece of work was to find out how to change the sql-select statements to get a full-tag cloud. Unfortunately, as far as I know, it is not possible to encapsulate this functionality in a WordPress plugin. you have to change your taxonomy.php (in wp-includes) manually. Thus, you have to do it again after every wordpress-update. – to the wordpress developers: would it be possible to include an option-field to select if not only post, but also pages should be tagged in future WordPress versions? – Anyway, in the mean-time change the two code-lines (which include the post_type attribute in the select-statement) as stated below. And don’t forget to add or delete a tag, because the tag_cloud is based onWordPress cache!
Statement 1 original code:
$results = $wpdb->get_results("SELECT object_id, term_taxonomy_id FROM $wpdb->term_relationships LEFT JOIN $wpdb->posts ON object_id = ID WHERE term_taxonomy_id IN (".join(',', array_keys($term_ids)).") AND post_type = 'post' AND post_status = 'publish'");
Statement 1 modified version:
$results = $wpdb->get_results("SELECT object_id, term_taxonomy_id FROM $wpdb->term_relationships LEFT JOIN $wpdb->posts ON object_id = ID WHERE term_taxonomy_id IN (".join(',', array_keys($term_ids)).") AND post_type IN ('post', 'page') AND post_status = 'publish'");
Statement 2 original code:
$count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts WHERE $wpdb->posts.ID = $wpdb->term_relationships.object_id AND post_status = 'publish' AND post_type = 'post' AND term_taxonomy_id = '$term'");
Statement 2 modified code:
$count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts WHERE $wpdb->posts.ID = $wpdb->term_relationships.object_id AND post_type IN ('post', 'page') AND post_status = 'publish' AND term_taxonomy_id = '$term'");
That should do the job. – Btw. the plugin from cybernet provides a useful click-list with all your tags in the edit section of the wordpress admin menu.
greetz berny
4 Responses to “WordPress 2.3 – Tagging Posts and Pages”
Feed available in RSS 2.0 and Atom 1.0
Show Comments on Map
leoniedu (1 comment)
says:
Tue, 11. Aug 2009 at 23:21 UTC | 1,377 days agoI had to modify the following lines as well. Did you have the same problem?
unction _update_post_term_count( $terms ) {
global $wpdb;foreach ( (array) $terms as $term ) {
$count = $wpdb->get_var( $wpdb->prepare( “SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts WHERE $wpdb->posts.ID = $wpdb->term_relationships.object_id AND post_status = ‘publish’ AND post_type in (‘post’,'page’) AND term_taxonomy_id = %d”, $term ) );
$wpdb->update( $wpdb->term_taxonomy, compact( ‘count’ ), array( ‘term_taxonomy_id’ => $term ) );
}
}Berny (44 comments)
says:
Fri, 14. Aug 2009 at 08:48 UTC | 1,374 days agohi leoniedu,
you’re right. – i assume that your code derives from the 2.8 branch? – the statements which one needs to modify changed during the last years…
basically on new wordpress versions i always look for all occurrences of
post_type = 'post'in taxonomy.php and change them topost_type IN ('post', 'page').that’s still a hassle, but it looks like there is no other easy way, as the wp guys still refuse to use tags for pages.
greetz,
bernyBerny (44 comments)
says:
Sun, 1. Aug 2010 at 02:24 UTC | 1,022 days agoThe follow-up of this post for WordPress 3.0 can be found here.
- TagPages review, discussions, does it work, and ratings on Loadwp.com | Loadwp.com
says:
Wed, 17. Aug 2011 at 18:21 UTC | 641 days ago[...] plugin is a follow-up to my post which I wrote a few years ago. – The idea was (and still is) to equip pages with tags and [...]
Leave a Reply
You must be logged in to post a comment.