Categories need to be passed as an array of integers that match the category IDs in the database. This is the case even where only one category is assigned to the post.
Currently you giving it a string of the category ID.
Try:
$category = array(intval($_POST['cat']));
Related Posts:
- Get Posts Under Custom Taxonomy
- How to display related posts from same category?
- How to show related posts by category
- How to add category to: ‘wp-admin/post-new.php’?
- Including categories in search results
- Use category base slug in posts’ permalink
- Different post sort order within different categories
- Count how many posts in category
- Custom Single Post By Category
- Setting Custom Sort Order of Posts within a Category
- How to get the number of posts in a selected category?
- MySQL Query to Retrieve Category from wp_posts
- Different number of posts in each category
- Display all posts from specific categories on a page
- Display the latest post from a category in a page
- How to show list of posts by author and category?
- Exclude posts that only have the ‘Uncategorized’ category [duplicate]
- Category checkbox list tree changes when editing a post
- How to add metabox for post of specific category
- Convert custom fields to post categories
- Manipulate post category after time
- Show related posts by category but ignore one category
- How to sort posts by last name (2nd word) on ONE category only?
- How to disable Uncategorized category URL?
- Add role that restricts user to post in specific category
- How to get Category Id from Post Id ?
- Count posts in category including child categories
- Query posts from current year
- Getting Position of a post in a category
- Display only posts from a specific parent category
- How to control which category will be picked for the slug of a post?
- Categories box not showing on post edit pages
- How to display comments and comment form on custom post type?
- get_the_term_list by hierarchy order
- How to change the layout and styling of posts according to their category in WordPress?
- I am trying to create a simple frontend form for posting
- List only child categories a post is in, of a specific parent category
- Add default content to post (for specific category)
- Query only Posts from Both of Two Category?
- exclude certain categories from posts
- ‘get_previous_post’ in same category returning (!empty) when no previous post in category exists
- List posts related to category on a div [closed]
- Taxonomy Category category.php not working
- how to show all post with its contents
- Change from all posts to specific categories post on main page?
- wordpress show category link instead of post link [closed]
- CSS – Change height of Storefront / WooCommerce product categories, but not products
- Post’s arent displaying
- Show with echo if a post has two or more categories
- excerpt in template for specific page
- Show Title/Date/Excerpt of first post & only Title for rest in Query [duplicate]
- Only show posts belonging to multiple cateogries at same time
- Wrap posts from a category in HTML
- How to display my categories in a list (to a post, not the sidebar)?
- How can I get on the same row two post of different categories?
- Polylang – display one post into 3 categories with different lang [closed]
- How to make category for word post_content
- How to sort the post to a specific category
- Listing category and its posts one by one
- Print out one of 2 post category [closed]
- How to get if category has posts?
- Show some texts in posts belonging to Specific category
- Export Posts Without Categories In An XML File
- wordpress category Description not allowed tag
- How can I add a custom caclulation form in post?
- View post with specific category id and name which I selected in the backend (drop-down option)
- Filter/Sort Post Form On Taxonomy page
- Site ‘Categories’: save an admin global setting with post metadata [closed]
- Sort Posts Alphabetically Based on Specific Category (Divi)
- 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)
- I have a blog and want to prompt the user to select a category they like and have that select a random blog post
- How to remove category and other tags from posts page
- I have a website issue I am trying to resolve
- How to sort posts alphabetically based on a specific parent category
- Get the category of post from which category page it have been clicked
- How to get a list of all posts and their categories?
- Show category name in category.php when posts assigned to multiple categories
- Category and archive issue
- Code understanding
- Error counting posts of category
- Adding content to the top of post’s based on their category
- Show posts assigned to multiple categories in current category page
- WordPress converting ‘ to ’ and – to –?
- Add a category to posts, that DO NOT contain two specific keywords?
- Menu for all posts from multiple categories
- How to display related posts from the same category?
- How to show related posts by detecting the current category?
- Display posts on a custom page from only a specific category?
- Preset category checkbox from URL parameter when creating new post
- What is the best way to publish News articles?
- WordPress menu disappears in category pages
- How to specify a post category for the home (posts) page?
- Unable to create categories and tags for posts in wordpress multisite
- Exclude the Newest Recent Post from their Category After New post Publish old post should be in their category at Home Page
- Menu item on a category
- Display posts from a specific category on frontpage.php template?
- Mismatch between posts count and actual list in admin posts page
- How to display blog posts per category using tabs or accordion?