Since Milo is a genius, I got this done much simpler by just looping through the array inside of the function, instead of trying to generate a new function dynamically for each item. The array contains ‘slug’ and ‘title’ attributes, and here’s the function:
function cx_product_field() {
global $fieldset;
foreach ( $fieldset as $field ){
woocommerce_wp_text_input(
array(
'id' => 'cx_'.$field['slug'],
'class' => 'wc_input_text',
'label' => __( $field['title'], 'woocommerce' )
)
);
}
}
Related Posts:
- Change the footer text on the login page
- How to remove a metabox from menu editor page?
- Check if page parent has certain template
- Hooking new functions to actions + passing parameters
- Is $hook a global variable in WordPress
- Insert all post IDs in new database table
- Randomise upload filenames (or another solution to hide the original image URL from theft?)
- Handling Body class based on Template
- Woocommerce: hook action/filter I could use to add variation id and price with each attribute opt on WooCommerce Rest api
- Why ajax doesn’t work on certain wordpress hooks?
- Is it possible to intercept all ajax requests and get the parameters and the returns?
- WordPress Gravatar filter is removing my custom attributes
- Error in custom php function doesn’t exist
- Generating an nonce for Content Security Policy and all scripts – How to make it match/persist for each page load?
- Return a numerical function value in Customizer controls
- Modify custom field input data before creating a new post
- how to make custom ajax handler?
- Omit custom post type from wp-sitemap.xml based on meta key using wp_sitemaps_posts_query_args
- Run a code only on theme activation only during first activation
- Theme not calling Jquery properly
- WordPress redirect redirecting too many times or not at all
- Why does the post_type_link hook everything twice?
- How to have different site identity logos on each page on Astra Theme [closed]
- How can I hook into the wp_mail function used by BackWPup?
- Get user custom field value on function.php
- Adding function to child theme’s function.php
- Must filter functions receive all arguments passed to them?
- Creating customized php files in theme folder
- How to pass hook variable to function?
- How do I add a function to parent theme
- Contain multiple page templates in one PHP custom template file in WordPress?
- Wp_Schedule_Event every few minutes doesn’t work
- Adding custom field to product category and show it to shop/category shop page
- Custom meta box is not displaying value showing tag as empty
- Discount in the specific product title using keyword ( Woocoommerce )
- How do I get the value of a current user’s custom field?
- Hook into all password resets in WordPress and get password before hashing?
- Getting page / post URL on publish and / or update
- Fatal error when using array_diff() function inside of wp_update_nav_menu hook?
- Why transition_post_type hook is called twice for the same post?
- WordPress HTML Helper
- Assign new post author IF another user in custom field on post transition
- Create and publish a new post every Monday, listing the post titles and links to the posts published during the previous week
- transition_post_status hook, works – but not if the post is new
- Is there a hook that I can use when a fatal error occurs?
- Cleaning up WordPress to improve performance?
- How can I modify the permalink via a filter?
- wp_set_object_terms and arrays
- How to use WordPress (PHP) functions in AngularJS partials files?
- The best way to customize “nav-menu-template.php” to add if the ‘link_before’ is “checkbox”
- How to Remove a Filter from the Admin List Table?
- Woocommerce, recognize the loop of related products
- Output a WooCommerce product custom field in WooCommerce using get_post_meta()
- enqueue multiple Google fonts with multiple weights and styles (italic)
- Can’t load WP function into external function
- Image as Sales Badge
- WSoD being caused by this piece of code
- How to Arrange PHP Files to Allow for Multiple Types of Pages?
- How to complete two other input fields, completed the first
- Retrieve $_POST data submitted from external URL in WordPress(NOT API)
- Why ajax doesn’t work on certain wordpress hooks and reload the page instead?
- Compare the old get_theme_mod($name) to the new get_theme_mod($name) return value
- Scrape external webpage for first image and add it to new post
- jQuery code not working when included in functions.php
- Fatal Errors on pluggable.php
- Log in / Log Out Custom Button
- Limit Taxonomy Output in Conditional Statement
- wp_redirect only works on main site and not on other sites
- Fatal error: Call to undefined function register_new_user()
- How to modify the default feed via a function
- require_once() if a product in woocommerce contains a tag [closed]
- Loop over Array and get the distinct ids
- How do I change this function from two returns to one string to show sku and dimensions in WooCommerce cart?
- Can not add admin notices from the edit_user_profile_update hook (notices not being displayed)?
- How to remove the space before the ellipsis in excerpt?
- Convert all uploaded PNG files to PNG-8 format
- Uses for function: wp_update_user
- How to Redirect Buddypress Directories To Login Page For Non Logged in Users
- Display logged in user name and lastname on page
- How to Add a cutsom slug to my custom author role
- How to output the taxonomies that are assigned to each custom post?
- Exclude category from function – PHP
- Hide a specific category title from displaying on site
- 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?
- Need help with AJAX login to call php in functions.php to handle redirects based on user cap (role)
- Populate Posts based on category selected using AJAX that means without page refresh
- PHP script to redirect traffic based on website accessed
- How to remove title tag with this filter
- Can’t get_users info by using json_encode
- What is wrong in this code?
- Page returning ID from array, how to return the correct values for post in acf wordpress
- Permission error on plugin save
- Removing all my hardcoded URLs with get_site_url()
- Display default WordPress login/registration form into a modal window
- Highlight main menu when on specific posts or pages
- Pull GET parameter from URL in functions.php
- Adding Gravity Form With if(is_page) Is Not Working
- Woocommerce – Shipping tax class based on cart items not using the highest tax available
- how to create twitter card without plugin in wordpress website?