To are still call database inside the by get_post_meta() where you already have the values in $custom_fields variable. Try something like this:
<?php
$custom_fields = get_post_custom($post->ID);
for ($i = 1; $i <= 4; $i++) {
if(isset($custom_fields["rw_location_$i"][0])){
if($i==1){ echo '<h1>';} else {echo '<h2>';}
echo $custom_fields["rw_location_$i"][0]
if($i==1) {echo '</h1>'; }else {echo '</h2>'};
}
}
?>
If I get your question right. Are you looking to echo <h1> for the first iteration and <h2> for all other iteration?
Related Posts:
- Need Help Fixing My Iframes [closed]
- Trying to retrieve post meta
- Saving zero in meta box
- Find a way to retrive data updated through metabox plugin to web page
- Why does this update_post_meta function not delete the custom field itself?
- How to store multiple custom meta box
- Problem with adding custom CSS class to image in ACF Photo Gallery plugin [closed]
- Display background color or image with custom meta box?
- Meta boxes only displayed when editing normal (default wp post_type) posts
- meta field for numerous links
- Custom fields changes the formatting of metabox input
- custom field meta-box with dropdown/autocomplete
- If custom field doesn’t exist, or exists and it’s true show title?
- Where can I find the code for the menu page meta boxes?
- Display custom meta box in my template file
- How to update custom fields using the wp_insert_post() function?
- Adding custom input for data attribute in insert media modal
- How to remove a metabox from menu editor page?
- Custom Meta Field – Youtube embed
- How to change “Shipping Calculator “field label on Cart Page – woocommerce? [closed]
- Using ‘strtotime’ function to convert a custom-meta-box to a date-stamp
- Print html when custom field has value inside while loop
- Update WordPress Custom Field with AJAX on cached page
- Saving metabox repeatable fields
- How to Explode a Textarea Field and Echo each line separately, wrapped with HTML
- WordPress doesn’t include css
- Understanding child theme functions.php
- Want to create Child theme, but already edited Parent theme css files and some php files
- Style every second widget?
- Put CSS inside a PHP file and include it the right way
- Register non hierarchical taxonomy and the show meta box in the post type
- Sum custom field values of particular taxonomy
- Customize Plugin
- Missing sidebar parameter “fix” – before_content
- Importing hard coded custom field into acf field
- Plugin CSS not enqueing
- How to use my style.css file outside of wordpress subdomain?
- Loop with slider (slider not loading)
- Can I install/embed WordPress on a ‘single page’?
- Remove metabox from WordPress menu editor page?
- Firing schema via code in functions.php doesn’t work
- How can I add extra word in permalink when someone click download button?
- Seach custom post type posts only by meta fields?
- conditional logic for front-end custom field edits
- How to add specific meta tags to head of cart and checkout pages in woocommerce?
- Use PHP in stylesheet to specify a background image based on Category ID
- WordPress wp_add_inline_style unable to give hex colors?
- How to create table in wordpress without plugin? [closed]
- Add class to DIV depending on page loaded
- Liking a facebook page from wordpress website?
- trouble with page_id & highlighting current page
- wordpress admin plugin menu custom css
- Show ACF field with link to ultimate member profile/WordPress user profile below the post (single post layout)
- Add editor toolbar to Metabox
- Issue Enqueueing WordPress style.css
- Applying CSS on PHP variable [closed]
- Add a counter for mouseovers (custom field)
- Show field if it has contents on Advanced Custom Fields
- the_meta – no get_the_meta query?
- Dynamically added custom fields not displayed on WooCommerce email notifications
- Timber right sidebar in WordPress theme
- How can I add diffrent editable text fields?
- How to Remove Theme Style CSS inside Custom Plugin?
- Include custom fields in search
- update_term_meta() only updating once on certain meta keys
- Add other class content with reference class value
- Adding Custom css file in the wp-uploads directory with custom php functions
- How do I integrate vanilla Javascript to a wordpress website?
- Cannot dequeue Elementor Font Awesome css
- How to find and delete a menu item in php?
- Generating 3 random numbers and saving them in database
- ACF – Can’t get custom post type by taxonomy
- WordPress Slider is not working
- How to display post meta bellow every posts
- Add Shortcode to ::before class
- Meta Box clears saved field content
- When working with a post, almost all wp_postmeta are deleted
- Displaying POST content with HTML tags and all
- What syntax is this? “{{post.price}}”
- Metabox – Displaying the Value of a Metabox
- Custom Thumbnails [closed]
- How to get the first letter from custom field?
- Meta box not saving spaces
- wp add inline style in loop
- Display pages from specific page template
- If Elseif Query
- How do I use CSS or PHP to customize WordPress Form Manager Plugin Table?
- Sidebar doesnt get updated?
- Add CSS class to PHP Statement
- How to add margin underneath woocommerce total price amount -> productpages
- Query posts by custom fields (object post)
- send meta box input data without publish button
- Load slideshow.css file only if Slideshow is checked / on
- Sorting Problem
- Custom HTML/CSS Theme into WordPress – SEO considerations
- why css file not link?how to create permalink?
- How do I organize posts based on their taxonomy?
- Shortcode Displays 2 times
- Using Featured Image as Hero Background in Word Press
- Hide or Show Read More Button by Content Area