My site has 3 main categories, let’s just say “A, B, C” and in them they have sub categories, “cat, dog, mouse”
The main categories have low # category id’s because I created them first. The way the original wordpress would work was that it simply would call on the lowest id #, as you very well know. But now with your plugin, it’s calling on the higher id # which works like this:
If category A’s ID is #10
and category dog’s ID is #22 (and dog is a sub category of A) here is how they show up.
In word press it showed up as http://www.test.com/A/title.html
With your plugin it shows up as http://www.test.com/A/dog/title.html
And that is exactly how I wanted it! This makes the categories very manageable because now I can simply add a new category and it’ll work right away.
With that said, I have not tested if it works without sub categories. I personally have a gaming site, so something like http://www.test.com/news/xbox/ is what I want. Either way, I think this plugin is a life saver
]]>I’m one of the heavy users of your great plugin, and I’ve just found a bug on it, that occurs when someone posts a comment or a trackback on some post.
For some reason, the savePost function gets called on every new comment or trackback, and it ends up updating the post_meta table, and since there is no data to update, it updates to the first category of the post (thus loosing any child category you might have choosen to be the master).
I’ve solved it by just checking if we are on the “post” page, before attemp to save anything.
Here is the solution:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | /** Store category permalink in post meta */ function savePost($post_ID) { /* Modified by Caio Proiete on 2007-03-25. Are we inside post.php or post-new.php? */ if (strpos($_SERVER['REQUEST_URI'], '/post.php') || strpos($_SERVER['REQUEST_URI'], '/post-new.php')) { /* Yes, we are... It's Safe to save/update post_meta table */ $category_permalink = $_POST['category_permalink']; $post_category = wp_get_post_cats('', $post_ID); if (isset($category_permalink)){ $found = false; foreach ($post_category as $cid) if ($cid == $category_permalink) { $found = true; break; } if (!$found) $category_permalink = $post_category[0]; } else $category_permalink = $post_category[0]; if (!update_post_meta($post_ID, '_category_permalink', $category_permalink)) add_post_meta($post_ID, '_category_permalink', $category_permalink, true); } } |
.
]]>To insert code sample please use <code lang="php">$your_code = "here";</code>.
Thanks!
]]>::HLIGHT_BLOCK_1::
I’m sure this could be done far more elegantly by someone who’s more knowledgeable about php and WP, but it does the trick. Maybe someone else will benefit as well.
Thanks again!
]]>Thanks!
]]>Best wishes,
Caio Proiete