To fix this you will need to pass in multiple terms rather than a single term
so instead of:
$_POST['main_cat']
Use:
array($_POST['main_cat'],$_POST['sub_cat'])
You shouldn’t need to save main_cat though. Assigning sub_cat should imply it’s also in subcat’s parent term
Related Posts:
- How to retain the values from dropdown category lists after wrong form submission?
- Additional form options based on category selected not working
- Exclude category from drop down list form
- How do I create a way for users to assign categories to a post from the frontend?
- Dropdown with category selection
- List custom post types in dropdown
- How to Make a Categories Meta Box with Hierarchical Checkboxes on Frontend?
- Get id of category from drop down menu
- How to add HTML5 ‘required’ attribute to wp_dropdown_categories() without JavaScripts?
- exclude category from WordPress Form function
- Help with multiple dropdown tags search
- How to use wp_category_checklist()?
- wp_dropdown_categories and custom taxonomy + custom post type
- How to provide value for ‘selected’ on wp_dropdown_categories() for ‘multiple’ options
- How do I create a way for users to assign categories to a post from the frontend of the website?
- wp_dropdown_categories() scripts working erratically on sidebar
- How to use an array of categories as a dropdown?
- wp_update_post is not updating category
- How do I display only two categories Instead of displaying all categories
- Dropdown Categories used in form shows no results when all is selected
- Trying to get variables in hacked category dropdown
- wp_list_categories walker without links on categories that have subcategories (to make a nested dropdown menu)
- Filter posts by categories ajax is showing nothing
- WordPress Customizer: Dropdown with Category output
- Filter By Category Dropdown List With Custom Taxonomies
- A dropdown with checklist
- Search form options group categories
- Redirect depending on category chosen
- Wp Dropdown Category Not Show Current As Title
- wp_dropdown_categories initial value
- Create a Category with a front-end post
- Update custom category fields front-end
- Why are my newly added categories not showing up when creating a post?
- Trying to get categories and sub-category listing
- front end add category to new post
- Get_term_meta() always returns false
- Woocommerce Category Sort Dropdown
- How to add custom option to wp_dropdown_categories?
- Default URL for category dropdown select option
- custom browse by
- Getting Custom post category from Form
- wp_category_checklist won’t show up for non-admin users
- How to Query the Top 5 Posts of a specific category?
- Get category fixed in dropdown browse categories
- Categories dropdown with all values selected using wp_dropdown_categories
- Front end page submission form does not attach custom post type
- add custom option to get_categories dropdown
- Taxonomy for custom post type not found
- Ajax call activate after submit in edit-tags.php page
- Form Value of drop down category + Translation of ‘show option none’
- Categories as selectable links on submission form
- How to add the category ID to admin page
- Filter categories using tags
- Show Post from parent category (custom taxonomy) ONLY!
- Add a wordpress blog to my website having users
- Allow contributors to add categories, but not delete
- in_category() not working in WordPress 4.9.7
- PHP Fatal error: Cannot use object of type WP_REST_Response as array in wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
- WordPress categories being called “archives” in google links. How to remove?
- Omit specific product categories from WooCommerce shortcode
- Category-slug.php not being used
- Pagination for category slug returns 404 when page >= 2
- Display category-specific comments in sidebar
- Paging not working in category.php
- Display list of categories filtered by date?
- Exclude category by slug in pre_get_posts?
- add slug beside name in Admin Category Checklists
- How to show 5 posts from specific category on related page?
- Exclude category from related post
- Post belonging to many categories
- How can you access category information from a theme?
- Filter WooCommerce archive pages by an additional category
- WP 4.7 in_category change?
- Display subcategories in dropdown
- Illegal string offset ‘taxonomy’ in
- Category Page Template – Can’t get category ID
- Are term_taxonomy_id and term_id the same? [duplicate]
- Filter Category Loop Dynamically
- SQL query to get posts from multiple categories but not in a category
- Can each user have only access to a private area (his own categories and posts)?
- WP Category Meta plugin fix? [closed]
- WP SQL Categories Export and Import
- How to display WooCommerce category image in my category page banner as a background?
- Order wp_dropdown_categories by ASC or DESC
- Displaying only selected categories
- How to get get_categories()’s ‘hide_empty’ argument to work with global year var in the archive template?
- Getting a sub category based on a category name
- How to display only sticky posts on category pages?
- I have many different products on my website how can I get them to display under specific categories?
- Help with SQL query, how to add taxonomie terms with value stored in options?
- /blog/ permalink prefix causes category pages to 404
- WP url to get rss with full text of post
- Display Referring Category on single post?
- Conditional statements based on custom meta value in category archives
- Placement of categories
- Display deepest post category, when post have multiple categories
- Paginate WordPress Category Pages
- Get a list of post titles and links from yootheme master theme
- Excluding cateory not working on my site. how to solve this? [closed]
- Get all first images of posts in same category