There’s the wp_update_post()
, also.
According to categories, please refer to the documentation.
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.
So, it would be something like:
$post = get_post($i = $post_id);
$post->post_category = array ($cat1, $cat2, $cat3);
wp_update_post($post);
Related Posts:
- WP 3.9 TinyMCE no longer loads on category description editor
- Change Gutenberg category checkboxes to radios
- Checklist of selected categories
- Multisite – Protect categories from deletion?
- Exclude categories from search query
- Why is per_page not working with categories in WP API?
- How to order the get_categories result
- List posts by category exclude current post
- In the tag archive – display count of posts for each category they belong to
- Custom color for each category name
- Listing all posts from current category on page
- Show posts of one category only with Custom Taxonomy on single.php
- Wrap a chosen category name with div
- Hide uncategorized products from the shop page
- Listing Parent, Child and GrandChild Categories and then the PostTitles on Page Template !
- Help with multiple dropdown tags search
- Category tree is flattened inside admin upon saving
- Get woocommerce catogry
- weekly archive for custom category
- Get last post date yesterday from each categories not work & double result post
- ?cat=-1 Indexed Versions Of Homepage
- .htaccess too many redirects based on category slug
- Multiple categories PROBLEM and Duplicating main categories
- using checked function to verify value against an array
- wp_list_categories depth and number
- Order categories by most posts
- Exclude category from fucntion
- Get Unique Categories – Group By?
- How to change category and year archive permalinks/rewrite rules?
- The Category page shows all the posts, without differentiating by categories
- New Categories Not Shown In the Post Edit Page
- Different templates for different category tags
- batch adding posts to a category based on matching regex for title with SQL
- Place category Base URL at the end
- Listing Texts of Which Custom Field is Null
- How to set a filter by category within a customised page
- Post Count for Categories, however not to calculate a total
- Flat category URLs but retaining hierarchy?
- Creating a custom feed for categories that includes the first post’s featured image
- Get categories without post
- Display thumbnails for certain category posts
- Hide the word ‘category’ from my permalinks
- School & class blogs – renaming/archiving post categories?
- How to modify default category widget list display?
- Building Menu from Woocommerce Product Categories
- How do I get the parent category if I know the child category?
- Is there a reason I cannot get the current category in a loop?
- How to get parent category ID in single page template
- List just subcategory and products of active category page in Woocommerce
- Custom Meta Box (SELECT2) Not Saving Taxonomy Terms
- Force category choice before creating new post
- Listing posts under a category by date
- Display content from a specific category using cat ID not working
- Deleting a category from WordPress admin does it remove it completely from the database?
- How to modify the “View all posts in category” title attribute
- Show post categories
- Exclude categories by ID
- Add description to categories menu in admin
- filter a loop base on specific category
- How to check if a categoryID exists in a theme options page
- How to display product categories and number of sales on WooCommerce
- Display one category and its suncategories
- How to differentiate the homepage structure from the category page structure in WordPress template?
- Last x Posted Categories?
- Get parent category field from child category [closed]
- Custom sidebar isn’t showing up on sub-category posts
- Is there a “sensible” limit to WordPress Categories?
- Can a Woocommerce product category URL contain “&”?
- How can I display all products from all categories on one page with woocommerce?
- get_the_category return empty inside loop
- Possible to make get_categories() hide_empty attribute honor excludes from post query?
- Function add class to second menu specific items if the page has a certain category
- How to call Primary Category for WordPress Woocommerce
- Meta Box: display single image on an archive-template
- Search Replace Database ONLY for posts of certain category?
- Conditional Site Logo(Category Based)
- Display only children of custom hierachial taxonomy
- Read More showing only on first post
- Tag Menu items based on their categories
- Filtered post assigned to categories
- How to exclude a specific categogy from a custom page template
- Transfering static site to wordpress and retaining category by month paginations
- Category Templates for Post Types not Working
- Change category base based on category
- altering theme – content generated by PAGES not PORTFOLIO
- Show only one category in main query, issues on tag page
- Bringing Ajax Loading Feature on Category Pages
- Need help with category page customization meeting certain condition
- How do i add custom post types to this query?
- add new input field like category?
- WordPress excerpt for specific posts in category
- How do I get a single page navigation depending on the previous page?
- Show category-ID in custom category-list
- Dynamically Adding Category Specific Content To Specific Category & Subcategory Pages
- Structure with category setting
- chose category in plugin
- Do not show all post from all categories, just show posts from category in current loop
- How to prevent page re-sizing for mobile browsers [closed]
- how do I exclude a category foreach
- CPT Custom post type Tags & Categories not showing for ‘Editor’ user in editor