the_field()
function shows the value and it doesn’t get/return anything. Like the_title()
and other template tags starting with the_
.
It means that:
This line prints the value and $hero
variable is empty.
$hero = the_field('hero_title');
This line prints only <h1>
tags.
echo '<h1>'.$hero.'</h1>';
What you want is:
echo '<h1>' . get_field('hero_title') . '</h1>';
Related Posts:
- Show/hide Widgets in Dashboard Based on Current Advanced Custom Fields Option
- How to use max and min values of custom fields
- Redirect to another page using contact form 7? [closed]
- How to retrieve the values of a sub-field in the first and last row of an (ACF) repeater inside function?
- Programmatically add Yoast meta description after post save
- Perform function on publish AND save (not just save)
- Reference multiple style sheets, clearing styles for permalink page, custom fields for css
- update_post_meta not working in function
- warning: trying to access array offset on value of type bool ACF field image group
- Unique sequential reservation code
- Default Custom Field Value Automatically Update
- Usage of theme name in functions
- Trying to retrieve post meta
- WebP Fallback for Inline Background Image in Style Attribute
- Functions.php Problem
- WordPress function saves a post twice and updates all posts
- Warning: Invalid argument supplied for foreach() [closed]
- How to customize the_archive_title()? Cannot figure out how to change the value it produces [duplicate]
- How to get correct value from checked()?
- Control the srcset much more (not all sizes in it each time)
- Check if the image size is available and if not use ‘full’ image size
- Way to store featured image width and height in two separate variables?
- Prevent custom field from being updated after first publish
- Remove Custuomize Sections
- Can we create our own theme’s function.php?
- Define PHP variable from a seperate API if statement
- Custom Behavior when Adding New Custom Post Type in Dashboard
- Excerpt for pages not showing
- get_pages() Returns Only One Item
- Some questions about how proper add 2 CSS file in a WordPress theme?
- Adding class to last list item? Not WP generated
- Add php code to wp_print_scripts?
- How to inherit field value from parent post into in child / sub post
- Access category within rss2_head hook?
- Show ACF field with link to ultimate member profile/WordPress user profile below the post (single post layout)
- Does size of a theme’s functions.php file matter?
- Functions php shortcode for displaying main menu with no child items
- Can set_post_thumbnail be used to remove a thumbnail?
- get_next_posts_link() returns no result despite available posts
- Nav menus all outputting the same links
- PHP 7.1 | Warning: A non-numeric value encountered in
- Compare meta key to current date in pre get post
- How to insert class in each list of categories?
- I can’t add CSS with functions.php
- Insert Address fields into function
- Getting the teaser text without overriding global variables
- Combine two active_callbacks into one on theme customizer
- Problem with adding custom CSS class to image in ACF Photo Gallery plugin [closed]
- WP Customizer API loaded into functions.php
- call_user_func_array() expects parameter 1 to be a valid callback, function
- why can’t i add front.css to my frontpage.php
- How to make custom comment fields required
- “options.php” not found
- How to store a number (coming from cookie) into query vars for later usage in other filters?
- How add body_class from wp_termmeta
- Using two loops in one WordPress template
- Is this an acceptable practice for WordPress theme development?
- What is the correct way to include my new functions and scripts in WordPress?
- wp_nav_menu work in functions.php but not in the theme
- How do I display a date correctly that is stored in the database as a backwards 8 digit number from Advanced Custom Fields? [closed]
- Sort and display pages with specific custom field (not tag)
- shorthand syntax for custom fields
- Rewrite Question Mark in Post Template with URL Parameter for clean URLs
- Insert a field with PREG_REPLACE – strange behaviour
- Fill empty custom field with other custom field
- contact form in template with jquery,validate and ajax
- Why a SlideShow (made using JQuery FlexSlider) can’t work if I load it form functions.php but work if I load it from my footer.php file? [closed]
- Why I can’t load my JavaScripts using an hook inside my functions.php file?
- Excerpt length: get first paragraph
- Display ACF category image on archive and single template files
- How to Display WooCommerce Product Price in WooCommerce Archive
- How to change text color depending on the number value (Using javascript)
- Woocommerce Variable Product Dropdown for Custom Shop Template
- Delete images from media library when user deletes an image from ACF Gallery
- Featured Image and Tags problem
- Override a Post’s URL with Advanced Custom Fields Function
- WordPress Function Assistance with Loop
- How to show ACF value under post/page title in wp-admin
- How to display an image before title text in menu items
- How to fix Function create_function() is deprecated in / themes
- Exclude specific post from query
- wp_set_object_term via js btn frontend
- Advanced method to control cache of enqueued style/script
- WordPress wp_dequeue_script remove all other scripts
- Filter works on last selection but no others
- Populate Product Regular Price with a calculated ACF Field Value
- How to update an image attachment’s alt text from a custom field when saving a post?
- Can I use ‘Featured Image’ as a hero image and a thumbnail?
- Is_Page doesnt detect my page
- Test CDN link from function.php or wp_enqueue_script/style?
- Help with with my function for wordpress
- How to customize archive widget only for cpt?
- wp_title() return random number
- Why does echo on functions.php not yield result in source code?
- Problem with multi checkboxes value in metabox?
- How to offset main query without affecting other queries and backend
- ACF Date Form in Custom Admin Field
- Assign IDs to headings in ACF using functions.php
- How Can I Concatenate A String With One Of My Custom Field Value Before Saving The Post?
- Add meta data in head from theme