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]
- How to display custom option field in woocommerce orders in admin panel?
- How can I modify all existing tags while keeping the urls themselves?
- Best practices regarding the creation of custom widgets?
- How to add a slide toggle to the Woocommerce-Layout__Activity-Panel area in the orders admin page
- IF Statement on Button to make it complete and “uncomplete” based on user action / click
- Create a new query in function.php to filter blog posts
- Gravity Forms Button Text
- Find resources dynamically loading and change or add to the url
- Add to cart php not working [closed]
- How to auto refresh when user change postcode
- Remove the product category module block from the Woocommerce product page
- how can I edit flexslider in woocommerce. [Urgent]
- Unable to login using username
- Word Press – Dynamic Content [closed]
- Limit length of first excerpt in the loop
- Insert image in WordPress with HTML5 tag and caption function
- how can I just add to parent theme function(s) instead of redeclaring whole the function
- woocommerce change currency per category [closed]
- Default Custom Field Value Automatically Update
- Multiple Loops Meta Data
- Move Custom Fields on General Settings Page to New Location
- Skeleton Child Theme Add Icon Bar to Header Flex Grid
- Redirect to another page using contact form 7? [closed]
- Why doesn’t is_page(id) work in functions.php?
- help I changed one currency in woocommerce and everything is ruined [closed]
- different style sheet for just one page template
- Functions when woocommerce isn’t installed
- How to override woocommerce.css?
- How can I use Woocommerce $product->get_attribute in functions.php? (if at all)
- Condition OR for current user ID
- How to change this simple code so that it sends the email notification after payment in WooCommerce?
- The Loop not looping?
- How to retrieve the current post’s generated featured image size?
- (Woocommerce) Order by price when entering specific category
- Custom Behavior when Adding New Custom Post Type in Dashboard
- Where do I store custom functions that call custom page template files?
- While loop with an exception after a count is reached
- Why There Is No “get content by ID” Function
- Custom HTML markup
- Use a shortcode to display custom meta box contents
- How do I pull excerpts from pages?
- Output loop to function return?
- Wp-query Order By problem
- issue with if/elseif in_array inside foreach loop display only one post
- Randomizing wp_tag_cloud() in child theme
- replace text in Sort Box
- login_headertitle is deprecated since version 5.2.0
- How to append classname to body tag if guest user
- add_filter to specific WooCommerce Category
- Woocommerce checkout field
- Where do I go to edit this area? [closed]
- Woocommerce image sizes missing from Appearance › Customize but not declared by theme
- add referrer to woo
- Replace plugin function with a custom function?
- Add attribute only to first image of every post via functions.php
- Way to redirect all Product Sub Category to its Main category Page?
- Add Login/Logout Menu Item to Primary Nav “My Account” Submenu [Woocommerce] [closed]
- Different favicon on different pages
- Genesis Framework: How to exclude a specific author from archive custom loop
- Problem with calling custom function in a foreach loop
- The_content and Preg_replace in loaded Iframe [closed]
- Create a Woocommerce product widget with category filter
- Delay a function, any function!
- 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
- How do i wrap woocomerce attribute in list?
- Remove any product that is featured from regular display loop [WooCommerce]
- Two Sections on Woocommerce Catergory Page [closed]
- Problem with images URL after filter applying
- How add body_class from wp_termmeta
- Adding product to WooCommerce cart [closed]
- Change WooCommerce add_to_cart Button Text?
- two search forms on the same page
- Function to replace comment’s accented characters before posting
- WooCommerce -> wc_enqueue_js not working [closed]
- Use existing image sizes for WooCommerce
- Insert a field with PREG_REPLACE – strange behaviour
- How to echo Widget Title in Custom Frontend-Template Box
- Optimize CPT-function with a loop
- New checkbox in custom widget isn’t saving data
- Linking Javascript in functions.php file
- how to display a page before the home page
- loginout function customization
- Breaking up multiple words and inserting an image after first word
- Function to check if custom page is used by page?
- 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?