Home Forums Plugin Support WP User Frontend (Free Version) Parent Category Toggler

This topic is: resolved

Tagged: 

This topic contains 7 replies, has 3 voices, and was last updated by  Rogier 5 years ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #9035

    Austin
    Participant
    Post count: 6

    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

    #9068

    Tareq Hasan
    Keymaster
    Post count: 2831

    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.

    #9098

    Austin
    Participant
    Post count: 6

    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

    #9181

    Austin
    Participant
    Post count: 6

    bump

    #9192

    Tareq Hasan
    Keymaster
    Post count: 2831

    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.

    #9194

    Austin
    Participant
    Post count: 6

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

    Austin

    #9573

    Austin
    Participant
    Post count: 6

    Works like a charm… Thanks Tareq!

    #16106

    Rogier
    Member
    Post count: 2

    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 8 posts - 1 through 8 (of 8 total)

The topic ‘Parent Category Toggler’ is closed to new replies.