[wp-hackers] Is this a bug?
Haluk Karamete
halukkaramete at gmail.com
Fri Apr 20 02:42:55 UTC 2012
Here is the code you can test it on a fresh install.
adding sub cats to wp programmatically causes weird behavior on the
dashboard. This has been a show stopper for me.
<?php
error_reporting (E_ALL);
//load the wp shebang into this page
include ("F:\inetpub\wwwroot\Accounts\Dev.tjara.com\ic2\wp-load.php");
//your path here!
define('WP_USE_THEMES', false);
//add a sub under the uncategorized
$Term = "Sub-UnCategorized";
$args = array('parent' => 1 );
//by assigning parent to be 1, I'm telling WordYress to make the
"Sub-UnCategorized" a child of "Uncategorized".
wp_insert_term($Term, "category", $args);
// this line will add the wp_term and wp_term_taxonomy records properly.
//this ends up getting the tt_id of 3 on a fresh install for the
//this is so because id 1 goes for the uncat/category, id 2 goes
for the blogroll/link_category tt_ids
//Let's add another sub under the above sub - making it a grand child of
$Term = "Sub-Sub-UnCategorized";
$args = array('parent' => 3 );
wp_insert_term($Term, "category", $args);
echo "Done.<p>Go check your categories on the dashboard now. <p>You
will notice that the Sub-Sub-UnCategorized is missing from the view,
even though the same dashboard reports that there are <i>3
items</i>.<p>But what's funny is the dropdown. Check the dropdown for
the <i>parent</i> selection, you will see that the missing
Sub-Sub-UnCategorized is there. Go figure!";
echo "<hr>In order to get the missing sub-sub into the view, you will
have to do two things. <ol><li>Add a dummy cat.<li>Click on the
categories link on the admin navigation.</ol>";
?>
More information about the wp-hackers
mailing list