I can see few potential issues here:
-
wp_insert_post returns post_id or 0 or WP_Error, if you will have WP_Error it will still pass the
if ( $porduct_id ). So here you have one potential issue. -
In description you wrote, that you create fields called “regions”, and in code you have
wp_set_object_terms($product_id, $regionId, 'region');so here we have “region” no “regions”. Not sure if you misspelled in the code or in the description. -
Last thing is here:
<option value="<?php echo $child_category->term_taxonomy_id; ?>"probably it should be$child_category->term_id
Hope any of this will point you to the issue.
Related Posts:
- error_log() output for print_r() appearing on page
- Allow only 1 taxonomy per custom post type [duplicate]
- Do I require the use of nonce?
- Retrieve multiple values passed to a single attribute in a shortcode
- How to change date language without changing the entire site language?
- Save selected item from dropdown menu in a meta box as a metadata value for a custom post type
- OOP Plugin Development. Including external object
- Authenticating to WordPress, using my own authentication two-factor system
- Use composer to load custom classes [closed]
- Why when I instantiate wp_error in a validation method my user registration method stops working?
- Create table in database when activating plugin
- Problem with WordPress Ajax form
- allow user to select pages from dropdown in my plugin
- Using Font Awesome as post thumbnail
- How to set a custom path, for ajax image upload folder in admin?
- admin-ajax.php responding with 0
- custom shortcode will not display the wrapped content
- How to restrict wp generate attachment metadata() to certain intermediate image sizes
- WordPress php filter admin_body_class not working
- Common abstract class for plugins
- Same log message keeps on printing to debug.log file thousand of times
- Append HTML Using Shortcode
- Create onClick Event to Re-load a Widget
- Accessing the database from a plugin outside of action hooks
- Adding subdomain to home_url for “add_menu_page”
- How to select the contents in the text view textrea in wp_editor?
- How to auto fetch customer details in Woocommerce in checkout page
- Can’t upload image using media_sideload_image
- I want to add custom add to cart link [closed]
- Execute long and heavy processes
- How can I hide that I Use WordPress (with W3 Total Cache)
- Saving plugin settings – ERROR: options page not found
- class_exists returns different values [closed]
- Can’t print Yoast meta description into page template (syntax error, unexpected ‘.’) [closed]
- Asynchronous multiple requests 401 Unauthorized
- Custom array from a query only write the last row of the query
- Using data sent via AJAX in multiple functions on a WP plugin
- Is it possible to define variables in a wordpress shortcode, and then call the shortcode using a specific variable?
- What does -> mean in WordPress?
- How to remove the message ‘We could not find any results for your search’ without changing template files and without adding posts/pages?
- How to add the sidebar to all the pages except the home page? [closed]
- Custom meta box values are not getting saved for my custom post type
- WordPress shortcode returns the data before
- Can’t upload CSV file to plugin directory using custom upload form in admin panel
- Validate and Sanitize WP REST API Request using WP JSON Schema?
- Set default Database Storage Engine when creating tables with plugins?
- Can I remove or edit an include() from a function with a filter?
- Call to undefined function error in plugin
- How do I make this Metabox show current DB value?
- Get category id when SEO URL is turned on
- Ajax on the Administration Side of plugin – wp_localize_script – how to pass value from JQuery to PHP function in class?
- Using ACF Relationship field to set post type to draft or published status
- WordPress can’t use ZipArchive
- How to extend SelectControl with data from my theme
- How to change basename url for wp-admin?
- Only the first image uploads
- WordPress loading progess – wp-blog-header.php
- Illegal string offset checkbox
- Custom plugin: how do I call a PHP file if settings option is set to true?
- Trying to use a variable to set image width
- How can i avoid duplicate same post in wp?
- wp_update_post gives 500 internal error
- How do I disable cache for a certain page?
- How to check if plugin update process completed in wordpress?
- register_setting not save checkbox
- using filter and hook inside class
- How does one make a URL return dynamic JSON with custom Content Type?
- How to give custom roles the capability to edit one Menu instead of every Menu
- Priority call methods – PHPMailer->addAddress(NULL)
- How to properly escape in ternary operators – Wp Coding Standards?
- Add Admin Option w/ Anonymous Function
- add menu page in loop menu order
- defined (‘ABSPATH’) false after AJAX post to other PHP-file
- How to send logs to plugin owner for a plugin?
- Force CSV download with template_redirect
- Private messaging – Getting and displaying the avatar/url of a message recipient
- How to use foreach and if statement within array of arrays?
- widget: input the px value from user and use it as inline style in widget function
- How to edit the default database of WordPress [closed]
- SHARING TO FACEBOOK – FROM DYNAMICALLY GENERATED PAGE
- Cookie not created in AJAX request
- How to automatically convert images to WebP on WordPress?
- Check user last login date
- Transate plugin with js & wp_localize_script
- WP Custom tables query
- Import js variables loaded via wp_localize_script() into js module without global scope connection
- Custom taxonomy with page post type – WordPress
- Redirect users by role to custom pages
- Query posts by custom taxonomy slug in WP REST API?
- oneOf JSON Schema validation not properly working for custom post meta value?
- Too few arguments at registering new templates in my plugin
- I want to lists posts in wordpress to nearest location entered by the user
- getJSON response to PHP
- Custom plugin with shortcode not working
- wp_register_script – illegal string offset
- How can I modify the html output of a custom post type admin page?
- Translate string in another langage than Locale
- Integrate a Custom Post Type with Learndash Plugin
- Remove slug of multiple custom post types with and without hierarchical
- Custom rest fields not loaded in rest api cpt response