Results 1 to 1 of 1

Thread: move all categories to a Parent Category

  1. #1
    Thread Starter
    Junior Member m4rty5miff's Avatar
    Join Date
    Jul 2010
    Location
    United Kingdom
    Posts
    45
    Thanks
    1
    Thanked 4 Times in 4 Posts

    move all categories to a Parent Category

    I need to move all of my categories to a parent catgory and was going to use the following function to achieve this

    Code:
    add_action ('init', 'general_parent_cat');
    function general_parent_cat() {
        $parent_cat_id = 1; // change 1 to the ID of the parent category
        $categories=get_categories(array('exclude' => $parent_cat_id, 'taxonomy' => 'category'));
        foreach($categories as $category) {
            // only if a category doesn't have a parent
    	if (!$category->category_parent) {
                wp_update_term($category->term_id, 'category', array('parent' => $parent_cat_id));
            }
        }
    }
    However with the use of custom 'Ad_Category' instead of the wordpress standard 'category' can somebody help me rewrite this function?

    Thanks
    Martin

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Need to move sub-categories from sidebar on main category page
    By bkirkham23 in forum ClassiPress General Discussion
    Replies: 5
    Last Post: July 25th, 2012, 11:12 PM
  2. Replies: 3
    Last Post: May 20th, 2012, 03:35 PM
  3. Show Ads/Posts from Child Categories, in the Parent Category?
    By dijitul in forum ClassiPress General Discussion
    Replies: 5
    Last Post: March 19th, 2012, 08:28 AM
  4. Show parent category in index, search result and category
    By setempat in forum ClassiPress General Discussion
    Replies: 1
    Last Post: January 7th, 2011, 05:02 AM
  5. Replies: 1
    Last Post: July 13th, 2010, 11:59 PM