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:
- Should I use spl_autoload_register() in my plugin?
- How can I save a multiple select array with the settings API for a plug-in options page?
- Include WP_Query in my own PHP file?
- Using register_activation_hook in classes
- Is there a way for a plugin to add an attribute to the tag of a theme?
- How to use update and delete query in wordpress
- Gutenberg Blocks doesn’t render correctly when using do_blocks
- add_meta_boxes action with refresh on save
- Resize Image without cropping
- My shortcode is showing up twice
- Database “Migration” for Plugins?
- Custom plugin issue when trying to use the shortcode twice on a page [closed]
- Does wp-cron runs all tasks scheduled at same time together or one after other?
- Making Quote Plugin more efficient
- Hiding WordPress Plugin Source Code
- How do I use the Simple HTML DOM Parser in plugin when other plugin already uses it?
- Will simple function names in a class structure conflict with other plugins?
- Instantiate class to be available to all plugin functions
- How to test nonce with AJAX – Plugin development
- wp_loaded hook block script enquequing
- WP nonce invalid
- Custom filter in admin edit custom post type responding with invalid post type?
- How can i upload images in an admin page?
- How to find error in my code when the error message is pointing to WP core file?
- How to access global variable $menu inside a class function
- Custom user login page by creating a plugin
- Singelton class does not work, multiple initialization on page reload
- Retrieve $_POST data submitted from external URL in WordPress(NOT API)
- How to upload a file to a folder named after the user_id via plugin
- Reprinting tags with all attributes
- Whitelisting items from custom options page
- Add_menu_page not displaying the menu in class based plugin
- Update results, Before deleting the related category [closed]
- adjust section according to country?
- Adding function to Genesis genesis_header [closed]
- how to update and display an option without reloading the page
- How to obtain the current website URL in my theme?
- What exactly do this function declared into functions.php file of a WP theme?
- How to use html inside a functions.php code?
- Plugin Generate Unexpected output during activation
- Extend Woocommerce Widget Class – WC_Widget_Product_Categories
- Undefined method class::construct() when creating a plugin
- Hook called before text widget save
- plugin add action hook is not working :
- zip unzip attachments in wordpress
- wpdb prepare insert table doesn’t work
- wordpress admin plugin menu custom css
- how to Update 15k products on plugin activation with meta_option
- Using admin-post.php for admin form but it directs me to admin-post.php white screen
- Hooks for post saving make a post-new.php to load latest post’s data
- How can I display Custom Post type Custom Columns and its Content in a Dashboard Widget?
- custom plugin with upload files does not work
- Using flickr api in custom wordpress plugin
- Toolbar Hidden in a Virtual Page
- What is the difference between Null vs Empty (Zero Length) string?
- PHP: $_SESSION destroyed after page reload for my custom session
- send popup after wp_redirect()
- no_rest_route error on custom routes
- How to correctly escape an echo
- Payment field disappears on custom Paypal plugin
- Adding image upload in tag section – WordPress plugin development
- How to Remove Theme Style CSS inside Custom Plugin?
- Create ACF Checkbox to get all ACF Values from Parent Page
- Creating plugin with front-end pages
- How to Send Pingbacks for all Posts in WordPress?
- I am having errors with checkout on wordpress
- File is executed twice if plugin is activating
- product_type_options get saved value [closed]
- Display a custom name when the user has no name settle in his account
- How can I update the price when someone enters postcode or zip code in woocommerce checkout page?
- 400 bad request admin-ajax file upload
- get Woocommerce product format json for WP_Query
- Sum All the Post Meta of Published posts of Current Logged in user
- Update user meta when an external link in admin notice is clicked
- Is there an option to execute javascript file only on plugin activation
- How do I remove an action hook inside a class that is called by another class?
- The plugin generated 225 characters of unexpected output during activation
- Autoloading Classes in Plugins
- Ajax in a class instantiated via shortcode
- Parsing webhook from Shopify in WordPress
- Comparing Dates within plugin using PHP If statement
- Shortcode Works for Logged in Users but Not Working for Guest
- Submit to itself don’t work
- WordPress / PhpStorm / XDebug and plugin_dir_path issues
- Singleton plugin activation; create database
- Send data from plugin to external database
- See output of a sql query while plugin installation in wordpress
- Why this plugin is not working?
- Permission error on plugin save
- How to get WordPress Adminmenu items?
- How to execute add_action() function from custom plugin to Crontrol plugin or do_action()?
- How keep woocommerce users separeted in multisite install and keep admins on network
- base64_encode conflict with convert_smilies in wordpress
- Displaying custom meta box value in a custom post page
- Woocommerce Convert existing order to the cart
- Redirect posts to post editor page based on query string
- how to check elementor is widget is active or loaded
- Create a custom plugin with dynamic child pages listing database records
- Load style and script for custom post type metabox
- Permissions error when I use my plugin to delete comments in the front-end