This topic contains 7 reply and 3 voices, and was last updated by Rogier 6 years, 4 months ago
Viewing 7 Posts - 1 through 7 (of 7 total)
Author Posts
October 15, 2013 at 10:56 pm 9035
Rogier Hi there, my site has many categories as well as child categories and child child categories (2500+). I used to use the free version with ajaxified category selection with a plugin called parent category toggler, and everything would work great. Since upgrading to the pro version, I see that the ajaxified category selector is gone (and I DO understand why you did this), however when I just use drop down, with the parent category toggler plugin, it doesn't select all parent categories. So if I have these categories, Michigan (parent) Michigan Fishing (child) Michigan Bass Fishing (child child) and I select Michigan Bass Fishing, I want it to auto select Michigan fishing and Michigan. It seems right now something is fishy, because as the categories are displayed in the upper left had of the post there are no spaces or / between the categories.... It gives me Home / MichiganMichigan FishingMichigan Bass Fishing / Post Name In the admin however, it only shows Michigan Bass Fishing as it's only category... Please let me know how to get around this issue as my whole site is dependent on these categories. Thanks, Austin
October 16, 2013 at 4:40 pm 9068
Tareq Hasan Tareq Hasan

I understand what you are trying to do, but that isn’t going to work fully. You can add multiple category dropdown using parent/child combination to the form and submit the way you are thinking. But that’s not going to work when editing a post. Take a look at this reply.

October 16, 2013 at 11:51 pm 9098
Austin Austin

How would I go about the multiple category dropdown using parent child…

I would love to have the ajaxified category list back in the Pro version. I am not worried about users editing their posts. Is there anyway I can add that to the pro version?

My site is fully dependent on these categories and I need some way that when a user submits a post with a child child category, that post is also listed in the parent categories of that child.

When I try using multiply selection, I do not believe it works as I can’t even select one category, it just highlights what I click and that is all……

Please help,
Thanks,
Austin

October 18, 2013 at 8:42 pm 9181
Austin Austin

bump

October 18, 2013 at 11:50 pm 9192
Tareq Hasan Tareq Hasan

Sorry for the delay between answers, I am actually in a travel mode.

Anyway, ajaxified category is not making to the pro version real soon for now. Paste this code to your themes functions.php and see:
[php]
/**
* Get parent category ID’s
*
* @param int $cat
* @return array
*/
function wpuf_get_cat_parents( $cat ) {
$cat_ids = array();
$current = get_category( $cat );

if ( is_wp_error( $current ) ) {
return array();
}

if ( $current->parent && ( $current->parent != $current->term_id ) ) {
$cat_ids = wpuf_get_cat_parents( $current->parent );
}

$cat_ids[] = $current->term_id;

return $cat_ids;
}

/**
* Update the custom field when the form submits
*
* @param type $post_id
*/
function wpuf_update_cat_parent( $post_id ) {
if ( isset( $_POST[‘category’] ) ) {
$cat_id = intval( $_POST[‘category’][0] );
$cats = wpuf_get_cat_parents( $cat_id );

if ( $cats ) {
wp_set_post_categories( $post_id, $cats );
}
}
}

add_action( ‘wpuf_add_post_after_insert’, ‘wpuf_update_cat_parent’ );
add_action( ‘wpuf_edit_post_after_update’, ‘wpuf_update_cat_parent’ );
[/php]

Use the category dropdown and if you select a child category, it’ll also assign the post to its all parent categories.

October 19, 2013 at 1:52 am 9194
Austin Austin

No Worries! Thanks for the reply… I’ll give this a try and let you know how it works. Thanks

Austin

October 29, 2013 at 6:53 pm 9573
Austin Austin

Works like a charm… Thanks Tareq!

March 3, 2014 at 3:54 pm 16106
Rogier Rogier

I am trying to get it to work for product_cat for woocommerce, but for some reason have not able to get it to work. Did somebody try if for categories used in Woocommerce? If so how?

Thanks in advanced!

Viewing 7 Posts - 1 through 7 (of 7 total)