class titleToTags { // Convert titles to tags on save: function convert($post_id) { $post = get_post(wp_is_post_revision($post_id)); // No title? No point in going any further: if(isset($post->post_title)) : $title = $post->post_title; // Only run if there are not already tags assigned to the post: if(!wp_get_post_tags($post_id)) : // Setup our tag data: $title_to_tags = array(); $stopwords = $this->getStopWords(); $title_werdz = explode(' ', $title); foreach ($title_werdz as $werd) : $werd = $this->lowerNoPunc($werd); if(!in_array($werd, $stopwords) && !in_array($werd, $this->wp_stop)) : $title_to_tags[] = $werd; endif; endforeach; // Finally, add the tags to the post wp_add_post_tags($post_id, $title_to_tags); endif; endif; }
There are currently 1 users browsing this thread. (0 members and 1 guests)