I did not actually test your code thoroughly, but on the first glimpse:
your form input is named post_category
while you’re grabbing $_POST['new_cat']
. Adjusting that (e.g., set both to post_category
) should already do.
// EDIT
And why are you grabbing $_POST['category']
in line 5?
Related Posts:
- how to create a category with wp_insert_post and post_category
- Manipulate post category after time
- How to get Category Id from Post Id ?
- Categories box not showing on post edit pages
- List only child categories a post is in, of a specific parent category
- duplicate posts when trying to update a post using the wp_insert_post.
- Add custom field to all posts in specific category
- is there a better way of combining this?
- How to choose a sort order (for posts) per category? (ideally when creating a new category)
- wp_list_categories link to first post of category instead of calling taxonomy template
- WordPress Child Category Display All Posts
- How to Add ‘Post Categories’ to the Dashboard Sidebar
- How only display all post related to category
- Add category to all post by using sql query?
- How to make search for the custom post type?
- Full Width Main Post
- How to automatically apply a category based on the post title?
- How to prevent duplicate posts with wp_insert_post on single.php?
- Pulling in post category and children within category
- Post categories to pages
- Get attachments for posts that belongs to a specific category
- WP_Query: Mixing category__in and tag__in together
- If in_category not working for multiple single.php pages
- How can I setup a relationship using categories in WordPress?
- Related posts by category not working right
- Set Default Category to Username
- How to Mysql select a list of posts with meta_values AND all relevant categories?
- Display post category in foreach loop
- Single.php – Get Current Parent Category
- How do I insert a post with custom post type and relate it to a custom taxonomy?
- When creating a post how do you select the format?
- get posts from Custom Post Type & Category
- How to enable custom Shortcodes in Post Category Description? [duplicate]
- Sort by last word in title
- How to call posts under a specific category on static front page?
- Give posts a particular template based on the assigned category
- Show posts on front page only
- Post-Archive like a page in a specific subdirectory
- Post is in descendant category not working in home.php
- How to get posts ordered by using their categories?
- Hide parts of the post content after typing it’s name or searching it by category
- SQL Bulk Move old posts by one author to another category
- How to display only one category in a custom post type?
- load more posts by category
- Get only X number of categories
- Display Related Posts by Category in Random
- inserting a category into post
- How to show beneath posts the full category path?
- latest post showing up twice on posts page
- wp_list_categories() Exclude All Categories Except One
- Different post views for different category views
- Possible?! A contextually titled back link
- Display Current Posts Category (with the most posts)?
- How to select a category automatically based on a word in WordPress post title?
- Only the most recent post is showing on my category page (working on localhost, not live site)
- How display related post only in Default category on single
- ACF date picker to trigger category change
- Get category slug of the Parent category of a Product
- How to add class to specific navbar item when post parent category is in specific category
- exclude particular category in api
- Posts are not displaying on their category and tag page
- Random post_id at wp_insert_post
- Make categories appear random
- Exclude posts in a category on one page but show those posts on a different page
- Excluding category from post navigation in WordPress?
- How to make a page show posts only from specific categories without editing php files
- Get posts from category from custom query
- Post Category link is same with Page link
- Show custom post category for single post
- Get a list of categories that are related to posts
- How to show posts ordered by random [duplicate]
- How to Get Position of a Post from a category and tag
- Display new posts categories in separated divs
- Querying posts from current category, using a variable as array argument
- Add Categories To Custom Post
- Query posts from newest category
- Display Posts by Categories
- Ajax – Post Categories and Load More
- Need help writing loop to display posts by categories in separate divs
- Edit Posts Page but not category specific pages?
- Query post category & remove any post id
- Multiple Post Repeat for Related Post Loop by Category
- How to organise post by category and date
- Show post if in category
- How to display custom content in post with category XXX
- Displaying categories items among posts
- how to show posts on different pages if number of post per page is one
- Displaying different posts Via wp_list_categories()
- Is possible to create a custom link that creates a post that’s already categorized?
- Is it possible to have different header style blog titles in different categories?
- How to display subcategory articles in the category view?
- Display ONLY Latest Post From Several Categories
- How do we display a certain category type on a page while hiding all others?
- Show all posts in category
- Is there any point to using wp_unique_post_slug?
- Polylang – display one post into 3 categories with different lang [closed]
- Export Posts Without Categories In An XML File
- How can I fixe the article title problem?
- Automatically select category based on user role
- Filters do not work when there are multiple (one works)