WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] saving category info without using the built-in category admin widget? (7 posts)

  1. iblastoff
    Member
    Posted 3 years ago #

    I am essentially working on a custom post type (for events) and need to properly save category info *without* using the default category widget.

    instead of the select boxes and allowing the backend user to choose however many categories they want, i want a dropdown box that only allows them to select ONE category from a restricted set of categories.

    so far i've been trying to implement the "wp_dropdown_categories" function and have been able to grab the proper categories i want and display them in my event custom post type edit page but i have no idea how to actually SAVE the post with the selected category.

    any code snippets/help would be greatly appreciated!

  2. iblastoff
    Member
    Posted 3 years ago #

    heres a visual depiction of my dillemma

    http://i53.tinypic.com/28inm8i.jpg

    (basically can't get the dropdown of categories to save upon publish)

    i also need to overwrite any previous category the post has been saved in (so basically only one category per post)

  3. iblastoff
    Member
    Posted 3 years ago #

    no one?

  4. mr49online
    Member
    Posted 2 years ago #

    Hi,

    Please, try to use this Default Author Category plugin.

    Hope this will resolve your issue. :)

  5. roblagatta
    Modern Tribe Support
    Posted 2 years ago #

    Thanks mr49online. I assume, iblastoff, that since you marked this "Resolved", you're all set here...but let me know if not.

  6. iblastoff
    Member
    Posted 2 years ago #

    thanks for the reply but that plugin was not what i was looking for. perhaps i explained my issue in an unclear way but i have since resolved it on my own:

    // steve lam - allows category update via the events venue dropdown menu rather than the sidebar category widget which is hidden in the events custom post type. this is needed because the crappy events calendar plugin only supports regular categories
    function event_venue_category($post_ID) {
    
    	$campus_name = get_post_meta($post_ID, '_EventVenue', true);
    	$venue_name = get_post_meta($post_ID, '_venue_campus_specific', true);
    	$event_category = array(
    	get_cat_id('Events'),
    	get_cat_id($campus_name),
    	get_cat_id($venue_name));
    	wp_set_post_categories($post_ID, $event_category);
    }
  7. roblagatta
    Modern Tribe Support
    Posted 2 years ago #

    Ah, excellent to hear you got this resolved on your own - great work. Thanks for sharing the solution too; hopefully other users who come to the forum with similar problems will find this valuable.

Topic Closed

This topic has been closed to new replies.

About this Topic