If I understand this correctly, you want the whole code inside if ($type == "payment-services")
to run only once.
There might be an easier way to do this, but a suggestion is:
- Add a variable with a certain value before your for loop (e.g. $run=”yes”)
- Put the code you only want to run the first time inside an if statement, where it only runs if the above variable has its initial value
- Change the value of the variable during the first iteration so the whole if statement is false during the rest of the loop.
So your code could look something like this:
....
$run="yes";
foreach($types as $type) {
if($run=="yes"){
if ($type == "payment-services") {
rest of code which will only run once
$run="no";
}
}
}
....
Related Posts:
- wordpress REST-API upload image to ACF
- How to add a custom field to quick edit
- Gutenberg First Block on Page Conditional?
- Comparing arrays with meta_query in pre_get_posts
- How to order by just the Time Field in Advanced Custom Fields
- Using Gutenberg parse_blocks Function With ACF Custom Blocks?
- Get specific repeater row (via advanced custom fields) based on Meta Query with Wildcards [closed]
- How to update custom taxonomy meta using ACF update_field() function or any other wordpress function
- Replace post’s “the_content” with ACF value
- PHP echo stripping formatting in Advanced Custom Fields [closed]
- Thumbnails generated from PDF in the “Media” section – how to show them in theme template?
- How to count ACF Flexible Content Rows?
- Query between dates using date picker filter breaks in WordPress 4.2.1
- Get ACF value after update user using save_post
- random p tag in advanced custom fields?
- How can I track and output when a field is updated? (currently using Advanced Custom Fields)
- How to write PHP array to render JSON-LD Markup for Job Postings, with ACF
- Add up values from ACF number field
- Advanced Custom Fields: Conditional Statement with Select
- Add PDF to ACF image field from file url
- Bulk-Update Custom Posts
- Group ACF repeater fields from differrent posts
- How to get custom fields in a post when published
- Get all custom fields with wp’s get_posts()
- How to populate a parent page with its child subpages and associated templates
- Find the first occurrence of a custom field
- ACF Add fields values to newly inserted post [closed]
- Programatically re-order images in the ACF gallery add-on. Orderby Title, ID, etc
- acf repeater was free in start [closed]
- ACF Relationship – Limit to specific pages
- Website goes down while importing backup (Internal server 500)
- Display total unique custon field results
- Advanced custom fields – pulling data in from another page
- ACF: If field contain a specific value, update value in another field programatically
- how to load random related posts with specific custom fields?
- Add original validation rule to Advance Custom Fields
- Displaying user data within ACF relational field (user type)
- ACF Image field not displaying in WordPress with Visual Composer [closed]
- Trying to select 1 item from an array
- Sorting get_terms, ACF is automatically removing duplicates
- How to acquire an ACF image using get_previous_post and get_next_post
- ACF checkbox array is returning numbers, not labels [closed]
- Building large multi-section pages with Advanced Custom Fields
- Showing a post depending on the Custom Field value
- Advanced Custom Fields – category image
- Widget Code / Advanced Custom Fields / Elementor
- How can I apply an ACF field to a single custom post if it refers to the taxomy of that post type in the rules?
- ACF: Update field value based on value of another field
- Getting “Years Only ” from ACF Date Picker field to Hidden filed in the fields group
- Prevent other hooks from firing after wp_update_post() outside of editor
- Where to place CSS if add a new layout to FLexible Content Template
- Trying to update repeater field (ACF) dynamically with data from Contact Forms 7
- Get title color from category custom field
- WP Cron Working, but Function Not Working
- How to get a product’s Custom Fields in a different template file?
- Explore custom posts (CPT UI & ACF) database from WP UI
- pre_get_posts hook not targeting search results page query
- ACF – get custom taxonomy term image field
- ACF group field disappeared after deployment using deployer script
- get the title of a relationship field
- ACF Dynamic select not showing data
- Modification of RSS feed is not consistent
- How to call ACF field in functions?
- Multiple orderby date arguments
- How to use WP Backery on Wysiwyg ACF
- How to use germ_terms() with meta_query for ACF Taxonomy field?
- Looking for a javascript callback action to re-initiate a custom slideshow in gutenberg
- Help using an array in ‘exclude’ key of another array
- Create Shortcode for php code in functions.php
- Display custom image field in user profile
- ACF: Updating gallery field doesn’t work in backend
- Pulling author name via $_GET parameter
- Front page showing ACF only once, is that solvable to show the ACF per post? [closed]
- Srcset incorrect with Owl Carousel and ACF?
- Rearranging Content After Blog Post
- Advanced Custom Fields – Google Map Won’t Render Unless Variable Dumped
- Add column and acf field content for cpt
- Call the cropped image of a custom field in the theme
- Relationship field problem: Uninitialized string offset: 0 in
- ACF iterating past the while-loop, defining a max number to loop
- Displaying page list and a custom field
- Gettext for custom field checkbox values
- How to add admin functionality to allow ability to choose different field group to display on webpage using Advanced Custom Fields?
- use advance custom field inside query post command [closed]
- Separate [Advanced Custom Field] values by commas
- Multiple loop issue – pull one featured and then continue the loop
- Advanced custom fields – If/ while field problem
- Check if meta_key exists in wp_list_pages
- ACF + WPML: How to translate date fields?
- ACF orderby not sorting dates correctly [closed]
- How do I convert an ACF field from a string to an integer?
- Using ACF custom field for custom post type to order categories
- PHP calls to custom fields not being made. Query seems to be blocking them
- How can i get custom field to apear on my wordpress admin area (post_type)
- How to indicate a parent child category relationship when bulk importing
- Get ACF time in His format
- Filtering custom post admin listing page elements based on acf user field
- Parsing value from Lottie JSON file
- How do I add an ACF shortcode to a non-ACF page?
- Convert acf/gutenberg markup to html