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
- ACF block gutenberg aligncenter don’t work
- Missing sidebar parameter “fix” – before_content
- Get different images for mobile and desktop with php, advanced custom fields without using js and ajax
- How Display Posts on category
- Importing hard coded custom field into acf field
- tracking number field in Woocommerce order [closed]
- How to stop featured image thumbnail [set as background image] on blog index page just repeating same image across all posts
- Slider loading issue
- Plugin CSS not enqueing
- Hide Hamburger Menu On Specific Page (Front Page/Home Page)
- Parent theme CSS overriding child CSS rules
- how to remove metadata from the posts of my blog?
- How can I create a list of page titles from custom meta values?
- How to select the contents in the text view textrea in wp_editor?
- Passing the custom field values in the wp_get_current_user array function
- How to style options page in dashboard?
- Theme Options Page – User Updates Logo
- Sort posts by custom fields value using dropdown menu
- How to use my style.css file outside of wordpress subdomain?
- Dynamic Stylesheet loads but doesn’t finish
- Can I prevent the user from adding more than two levels deep of terms inside of a taxonomy metabox?
- Image media upload metabox
- How to add date to navigation bar
- Custom profile field with birthday. Troubles with
- Loop with slider (slider not loading)
- Selectbox in admin panel function linking to CSS
- Linking text within textarea of custom meta box
- Can I install/embed WordPress on a ‘single page’?
- WordPress – Display array data of a child
- Using if/else statements with output from theme options
- Is there CSS to expand the gallery limit on Index Pages?
- wordpress allow user to edit user profile with custom fields
- Why do WP_Query results change after updating unrelated Advanced Custom Fields (ACF)?
- How to design a table based on css values set from admin/dashboard
- Store multiple custom field as post meta per post(css, js, html, 2 link) [closed]
- How to VAR_DUMP a $variable during checkout process (Is my product meta callable?)
- Remove metabox from WordPress menu editor page?
- Firing schema via code in functions.php doesn’t work
- MetaBox body is not showing (the callback function)
- Adding number to date not working [closed]
- How can I add extra word in permalink when someone click download button?
- Saving and Restoring a Canvas on A Individual User Basis
- Seach custom post type posts only by meta fields?
- Incorrect MIME type for assets with Valet
- How to display pictures from database?
- How to use thumbnail size of image if I’m only using src to get image
- How to add condition in wordpress loop? [closed]
- 3 Slashes appear after Apostrophe in custom fields after updating product-site
- how to retrieve a value if a checkbox is checked
- Customize position of social icons in upme plugin [closed]
- Trouble checking if custom woocommerce checkout field is empty or not
- Two queries for a WP_User_Query search work perfectly apart, but not together
- Best way to schedule daily change in CSS parameter
- Css loads very slow [closed]
- Gravity form built in Captcha
- How does wp_enqueue_scripts work?
- Different post styles depending on category
- How create a Shortcode with hover and complex options
- WordPress Multiple Navigation bars
- auto-populating custom nav with all items from custom post type
- Add / Update Custom Fields After Select Pictures in Media Window
- conditional logic for front-end custom field edits
- two columns of posts on homepage, one of them “favorites”
- Auto 301 to full post permalink? (using : /archive/%post_id% to %post_name% )
- Whats the proper way to use a php stylesheet in a wordpress theme? [duplicate]
- Automatic Shortcode Creation with Custom Fields [closed]
- Custom field values to taxonomy terms
- can i fetch a custom metabox data in another page or post type?
- custom css for admin only
- WordPress from url get external source title
- responsive.css in the WordPress should be prioritized
- How would an if statement surrounding a custom field with two variables (holding values) look like?
- How do I add a custom css to all posts without affecting homepage css? [closed]
- Redirect to another page using contact form 7? [closed]
- Which is the correct way to conditionally enqueue a CSS file?
- Custom Background by Page IDs
- proper way to add css using functions.php?
- WordPress style.css not updating, only after theme reload
- How to add specific meta tags to head of cart and checkout pages in woocommerce?
- Adding logo to WordPress header
- Add additional field to custom post_type
- Limit checklist by the current user
- Thumbnails appear to be zoomed
- Custom Field IF/ELSE PHP
- Use PHP in stylesheet to specify a background image based on Category ID