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
- Most efficient way to add javascript file to specific post and/or pages?
- Display all values of custom a field created with ACF on a page
- If Custom Field is empty don’t display div
- the_author_posts_link css class
- wp enqueue style and style sheet depth
- CSS saved & enqueued, but wordpress doesn’t load css text, only file
- WordPress loop specific thumbnail size
- Is it possible to use the featured image of a page as a css background without inlining?
- How to display a value from a radio button in the options menu in wordpress
- How should I best target dynamically served content?
- How to scale image with equal width and height without distortion?
- php syntax – how to concatenate properly – echo bloginfo(‘stylesheet_directory)
- how to increase custom post value by one most efficiently?
- Problem adding class to body_class
- Passing the custom field values in the wp_get_current_user array function
- Gravity form built in Captcha
- How does wp_enqueue_scripts work?
- auto-populating custom nav with all items from custom post type
- Whats the proper way to use a php stylesheet in a wordpress theme? [duplicate]
- Automatic Shortcode Creation with Custom Fields [closed]
- How would an if statement surrounding a custom field with two variables (holding values) look like?
- Limit checklist by the current user
- height should be set to auto to avoid pixelation in the post thumbnail function
- How to convert select to HTML with PHP tags inside of it [closed]
- Show meta box only for default page template
- Add Codepen animation as Preloader to WordPress
- Reduce size of responsive title
- How to check if a PHP string is different than meta field?
- Clickable image link sends people to wrong URL
- Only show image from custom field when present
- Creating a mobile site by adding a new class to the body tag from functions.php
- Hide Heading if ACF Field is empty
- Custom meta box values are not getting saved for my custom post type
- WP_Query: getting posts where custom field exists
- Creating an image from a custom field
- User Meta Value not echoing despite Var_Dump Showing correct string
- Split site title and apply different classes
- How do I make this Metabox show current DB value?
- Unable to render custom field after attempt to generate a list of recent post in page template
- Unable to Call More than One Meta Box Output
- Dynamic CSS through PHP issue
- Assign Custom classes to every Excerpt
- Conditional On custom field plugin metabox
- WordPress stripping out custom field tags
- Adding a navigation page state to individual blog and portfolio pages
- Using an “IF” statement based on the existence of custom field
- Inline CSS header style priority function.php Child (no enqueing I think)
- Woocommerce Custom Meta Boxes- How to only display if they actually have content
- How to put search bar & logo in the “primary navigation” storefront theme?
- How do you save the values from custom fields to a products data
- How to add a CSS class to this php code [closed]
- Dropdown category field inside repeatable metabox
- Products listing check if meta checkbox is checked
- Is it possible to update the dataset using update_post_meta
- Use CSS tag inside PHP code
- Warning: Use of undefined constant all – assumed ‘all’ (this will throw an Error in a future version of PHP) in C:\Users\…….. on line 6
- how to add functions to my function.php using a child theme?
- Replace header with large image on home page only, using Genesis child theme
- PHP/CSS: Shortcode won’t display correctly, and only displays in the head (before content)
- Get field in readable word
- Using Sprit-sheet on WordPress categories
- Add class for the_post_thumbnail_caption()
- Get value of submit button in custom post type
- How to include different html tags in the header for different pages?
- Get meta_query value by user meta array
- Font-Family does not looks like how it should be [closed]
- Include a custom field in mysql query
- How to add style in functions.php depending on conditions?
- Modify arguments for parent theme’s `wp_register_style` via child theme
- Hide button based on PHP result
- How to have Function of a plugin using global vars into a shortcode?
- Child theme not working properly
- How to link a word comprised of a custom field with another?
- How can I put a custom field as the link of a button shortcode?
- How to Publish WP original Source metabox value on front-end webpage
- How can I create a menu items from meta box based on users input
- Cant get theme to change footer color through theme customizer
- Changing 2011 theme header image based on user dropdown
- I want Page titles and excerpts to show up on home.php in certain order
- How to create and add js and css file when server is not on my PC?
- which php or css file has generated an inline style in WordPress that overwrites my css
- ‘This Field is Required.’ is Not Displaying on CF7 [closed]
- REST API custom endpoints for metaboxes
- How to initialise WP_Query on the basis of a specific meta_value and continue iterating rest?
- Custom Admin Menu Report for Specific User ID