wp_set_object_terms
Works better with term slug instead of term id so change this line:
$cat = array($category->term_id);
to:
$cat = array($category->slug);
Related Posts:
- How do I get the category URL from get_the_category?
- How do I use the same post slug for different Categories?
- Rewrite rule page url with category
- How to add the category ID to admin page
- Create terms when registering taxonomy?
- How to create non-unique sub-category slugs?
- Rewrite category slug
- Using same slug name for a page and category
- I use same slug name for category and page
- Divi change project slug based on category
- Removing the number in a category slug
- Add custom taxonomy terms to WordPress menu dynamically & append #slug to url
- Plural Category Base Slug On Category Archive Page
- On Category page, How can I get the category ID?
- Return category slug / title from category ID
- Duplicate Category and Page URL loads Category instead of the Page
- Category slug $_SERVER[‘REQUEST_URI’];
- 403 forbidden on one page only
- Get the name an the description of a link category
- Using a portfolio_category slug in wordpress URL
- How to get category URL with the slug?
- Categories vs. Page Site Organization
- WooCommerce duplicate sub categories and product slugs
- How to view WordPress’ default category IDs?
- Need to pull parent category and slug – only pulling daughter category
- Pagination for category slug returns 404 when page >= 2
- Displaying a full post instead of a slug per category?
- wordpress sub-category ( lowercase letters + non-latin characters ) = 404
- The default code for “posts_nav_link” on category.php isn’t working
- Mod_Rewrite to show only last subcategory in URL
- Style category link depending on category ID
- Get posts from specific taxonomy term
- how to get full category path including parent and subcategories
- Automatically redirect a page to a category that share the same slug
- Use the category name instead of category slug in permalinks
- How do I add a tag slug to a category URL to filter posts?
- Change of category structure will cause two kinds of URLs for one post
- Change slug of Standard wp Post category
- Edit tag_id in category pages of dashboard
- How to get selected taxonomy or category ID if using custom walker?
- How to remove the category from post slug
- Ordering categories by slug vs. name
- Check is category parent with ids from the childs – get_term_children
- Echo Category Nicename
- pagination 404 error, same slug home and categories
- Different post slug based on archive
- A different permalink structure for different categories
- OK to redirect the root WordPress category slug?
- How Can I Use Equal And Question Mark In Category Slug?
- How to remove category name for only one category?
- How to prevent WordPress from redirecting single page to prefixed category archive with same name?
- Include a page’s “category” in its URL
- Using the slug of a custom post category as prefix for the underlying custom post slugs
- Change the full slug for a specific category?
- Get category from slug list
- Store All Post Categories In Array
- How to auto update post title and slug with category name when post status is updated
- Hide category name using mod_rewrite
- Show only one of the categories of a post in the breadcrumb?
- hierarchical taxonomy in permalinks? using same slug
- woocommerce – products by category slug? [closed]
- Category slug in in loop always the same?
- How can I get rid of the the category suffix–NOT “prefix” (i.e. foo-1, foo-2, etc)
- How to get category slug link? ( include parent categories)
- How to define category ID in an array?
- How to add custom prefix before category base for category page URL?
- has_category() for parent category
- Getting the sub category
- One WP install, I need to map a custom domain name to each category
- Show thumbnail for category?
- get_the_category_list() does not give me all my categories
- How to disable category without deleting?
- Limit number of terms that a custom taxonomy can save per custom post type
- Category pie diagram meta box in post editing page
- Exclude current post from loop
- WordPress Categories in data-groups
- How to order get_categories() in the same order as the menu?
- Difference between wp_list_categories and get_categories
- Show different menu on each woocommerce category page
- Have posts that belong to multiple categories, exclude some categories from homepage
- Retrieve post tags from from main wp_query
- Listing Post Categories on Home Page
- Get posts in a subcategory of a chosen parent
- How can I only display links from a child category
- Category Template – Show Last Entry as Featured
- Hide category name but show posts
- Count how many posts have a specified tag AND category
- Post List by category and under custom taxonomy
- Balance Tags to the_content Words Length
- How to create template for children category?
- Display a category name automatically using code in the functions.php file
- Removing categories, Comments etc from posts?
- Problem importing categories and sub-categories
- how to ask if in two categorys inside if
- How to show video from wp option value?
- Changing Woocommerce categories programatically
- Add an Exclusive or featured tag line to article titles
- How to list out post category name and description in page
- Order Categories by Character Count
- How to remove the category from the url only for a specific category of articles on wordpress