Just loop over WP_Query::$posts
to get the titles:
$option_posts = new WP_Query( [ 'post_type' => 'organisationer' ] );
$options = [];
foreach ( $option_posts->posts as $post ) {
$key = "option_{$post->ID}";
$options[ $key ] = apply_filters( 'the_title', $post->post_title );
}
woocommerce_form_field_radio(
'custom_field',
array(
/* … */
'options' => $options
),
$checkout->get_value( 'custom_field' )
);
I’m not sure what exactly woocommerce_form_field_radio
expects as parameter. Maybe you have to flip the key and value in the associative array $option
. But this is basically how to get a list of post titles from a query object. You may also consider to remove the the_title
filter, depending on your needs.
Related Posts:
- Woocommerce add to simple product attribute programmatically [closed]
- Adding WooCommerce to a Custom Theme – not working [closed]
- Display WooCommerce subscriptions for user [closed]
- Set quantity of woocommerce product on page visit [closed]
- How can I remove the main description text box in a Woocommerce product editor page? I only use the “Product short description” text box [closed]
- When sale price is 0.00 show only regular price
- Create custom function for hero image
- Woocommerce Variable Product Dropdown for Custom Shop Template
- Parent category as WOOCommerce Categories widget title
- Woocommerce custom calculation function
- Post variables not displaying correctly in custom function
- Copy and Modified WooCommerce function is_coupon_valid [closed]
- Add multiple custom fields to the general settings page
- How to display custom field in woocommerce orders in admin panel?
- how to override woocommerce specific loop or archive-product.php [closed]
- Is it possible to remove the “standard” post format?
- Issue with get_theme_mod returning a blank value instead of the saved value
- How to remove row-actions from pages table?
- Show modified time if post is actually modified
- Modify search function in WordPress (TwentyTwelve)
- Auto delete WordPress images/thumbnails (all sizes) and featured after X days/hours, or similar?
- How to fix a theme with page.php Default Template that accidentally deleted?
- How to Acheive the custom woocommerce category template
- How do I change parameters without changing the core
- WordPress – thumbnail image from youtube (function and loop)
- Problem with extract() with custom shortcode
- Hide some items from Screen options in dashboard for products
- delete an array element when its date expires
- add sidebar area to header of child theme
- A snippet after every image
- Function to show only first instance of shortcode
- Show post page only if the user has bought a specific product
- How to use max and min values of custom fields
- Increment price for Woocommerce Minicart [closed]
- Change woocommerce products weight varation based its product category or tags? [closed]
- Pass Shortcode Attribute to footer Script
- Woocommerce checkout field maxlength, make input number field only (postcode)
- PHP files included in functions.php don’t seem to work
- change in form-checkout.php by using code in functions.php
- How Can I Expand the WordPress Customize window without any Plugin?
- Automatically wrap multiple images in div
- Ajax not working properly
- Create a new query in function.php to filter blog posts
- Remove the product category module block from the Woocommerce product page
- Why doesn’t is_page(id) work in functions.php?
- different style sheet for just one page template
- Functions when woocommerce isn’t installed
- While loop with an exception after a count is reached
- How do I pull excerpts from pages?
- Output loop to function return?
- replace text in Sort Box
- login_headertitle is deprecated since version 5.2.0
- add referrer to woo
- Add attribute only to first image of every post via functions.php
- Different favicon on different pages
- Problem with calling custom function in a foreach loop
- Auto scroll to id on page load on all pages except home page. Only do this on mobile
- Get term slug by term id and then explode it
- Using functions.php to include code that’s processed inline
- Adding product to WooCommerce cart [closed]
- Insert a field with PREG_REPLACE – strange behaviour
- How to echo Widget Title in Custom Frontend-Template Box
- how to display a page before the home page
- loginout function customization
- implementing a centralized content “show-do-not-show” toggle?
- How would I make a function to dynamically determine if user is logged to change navigation menu text?
- How to display this meta data (an array) in form of a function (created with a custom write panel)?
- WordPress – using sessions?
- Customise Grouped Product display in Woocommerce with custom column
- How to hide content on mobile in the functions.php file – woocommerce
- How to remove font awesome from loading in wp theme
- Header menu aligned right on all pages except for single-post page [closed]
- update_user_meta as multiple value but with same meta key
- Hide ‘add to cart’ when certain value in dropdown is selected
- Remove text after a dot and a colon in Woocommerce product title
- Help with with my function for wordpress
- Remove clickable Link of WordPress Site Logo from Woocommerce Single Product page
- Problems adding a new field to product in cart
- Extend WordPress Audio Widget to accept HLS (.m3u8) URLs
- How Can I Concatenate A String With One Of My Custom Field Value Before Saving The Post?
- How to use `foreach()` in ajax call
- Variable function names
- add product thumbnail to checkout page only and include variation name
- WordPress Ajaxifying not working properly
- WordPress function with attribute pass to template
- Will dequeueing in child theme functions.php file prevent Google Fonts from loading?
- Which method is more correct for removing WooCommerce Extensions menu item?
- Adding A New Widget to WordPress Disables the Existing Widgets
- Help! Need a different logo on my main page from my other pages
- Display page number on custom page title function
- How to replace words in my posts and saved new words
- Insert menu into theme location depending on user logged in/out status
- Add functionality to post editor
- Why does modifying my functions.php file always result in a server error
- Remove snippets of JS from core
- how to handle multiple forloop?
- reusing code in function and running it with loop
- Explode Array from Repeatable Custom Field
- WordPress Custom wp mail template return full template
- Update post meta with wp cron