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:
- How to display related posts from same category?
- How to show related posts by 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?
- How to disable Uncategorized category URL?
- Add role that restricts user to post in specific category
- Count posts in category including child categories
- How to control which category will be picked for the slug of a post?
- How to display comments and comment form on custom post type?
- Query only Posts from Both of Two Category?
- Show Custom Taxonomy Categories, Listing of Posts, and Single Post via AJAX
- Archived Posts in Wrong Category
- Post in Multiple Categories to stay in current category (permalink, next previous post link)
- Display all posts under child sub category in sidebar on post page?
- How do I get the slug of a custom taxonomy category of a post?
- Featured Posts for Category Pages
- Authors in menu, template list post by author
- Count to how many categories a post belongs to
- Exclude posts from featuring
- How can I remove posts of a certain category from homepage after a specified time period?
- Articles are text-only in any “Category” instead of HTML
- Edit custom post type admin menu link
- How to display WordPress archive into three columns [closed]
- Get mixed category random posts
- Using wp_list_categories like the the_category (showing just current categories of a post)
- Should I use posts or pages in this scenario?
- Assign category to new post via URL
- Category Page Template not Showing Posts
- How to allow users to post only in certain category and hide elements from edit page?
- How to Restrict Previous & Next Post Link to Posts of Same Category?
- WordPress custom Query for Posts in Category display posts multiple times
- Need help with category listing!
- Prepending %category% onto default posts fails
- List all categories with featured image from post?
- Categories list into registration form
- Related posts by category not working right
- How to list recent posts in a wp nav menu?
- Listing Specific Categories from Current Post with Depth
- How to display two blog categories as separate sections on one page?
- How to Mysql select a list of posts with meta_values AND all relevant categories?
- get_the_category listing in hierarchial order
- why does wordpress ignore the post args?
- 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?
- Show posts on front page only
- 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
- Display Related Posts by Category in Random
- How to show beneath posts the full category path?
- Standalone form does not post to the url when form fields are populated (otherwise it does)
- 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)
- 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
- Make categories appear random
- Exclude posts in a category on one page but show those posts on a different page
- 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
- Add Categories To Custom Post
- Query posts from newest category
- Display Posts by Categories
- Ajax – Post Categories and Load More
- Edit Posts Page but not category specific pages?
- Query post category & remove any post id
- Changing a field value on submit using a PHP variable
- 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?
- User driven content problems
- 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?
- Viewing category won’t show up Custom post type posts
- Show Title/Date/Excerpt of first post & only Title for rest in Query [duplicate]
- Show some texts in posts belonging to Specific category
- How to show related posts by detecting the current category?
- Display posts on a custom page from only a specific category?
- What is the best way to publish News articles?