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
- How to display custom field in woocommerce orders in admin panel?
- Issues with title-tag and document_title_parts
- Is it ok to use a function to output the text domain name in a wordpress theme
- Get a list of all available fields in the User Profile
- TinyMCE custom styles remove class when switching styles
- Enabling shortcodes for custom fields
- Add options to featured image
- Overriding core functions in child theme
- Change parent theme file function in child themes functions.php
- Dequeue Scripts and Style for Mobile not working?
- Assign category using custom field?
- Function to Download External Images to My Site
- Displaying Widgets
- Best Practice for Syncing Local Development With Staging Development [closed]
- Overwrite Parent Theme add_image_size in Child Theme
- Show excerpt for only first post in query
- How to add css class to image attached in all the posts?
- Is there a way to add a class to non current menu item?
- When using wp_enqueue_script(); in a theme why don’t we use add_action?
- How to use Internationalized human_time_diff() function in Chinese?
- is_dynamic_sidebar always returns true while using Jetpack visibility
- Retrieve tags data in post body
- Add caption functionality to custom WordPress theme
- Override a theme function in a child theme?
- Pulling Twitter RSS feed not working as expected (fatal error)
- Use register_setting() in a loop
- Add dynamic links in WordPress custom theme
- WordPress menu link doesn’t work properly
- Search filter by Post title OR Meta Title Value [duplicate]
- admin-ajax.php + load-scripts.php hanging for minutes
- Unique sequential reservation code
- Default Custom Field Value Automatically Update
- 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)
- Prevent custom field from being updated after first publish
- Some questions about how proper add 2 CSS file in a WordPress theme?
- Add php code to wp_print_scripts?
- How to inherit field value from parent post into in child / sub post
- Functions php shortcode for displaying main menu with no child items
- 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
- 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
- Insert a field with PREG_REPLACE – strange behaviour
- 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?
- Display ACF category image on archive and single template files
- How to Display WooCommerce Product Price in WooCommerce Archive
- Woocommerce Variable Product Dropdown for Custom Shop Template
- Featured Image and Tags problem
- Override a Post’s URL with Advanced Custom Fields Function
- WordPress Function Assistance with Loop
- Advanced method to control cache of enqueued style/script
- 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?
- 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?
- Why does echo on functions.php not yield result in source code?
- Problem with multi checkboxes value in metabox?
- How Can I Concatenate A String With One Of My Custom Field Value Before Saving The Post?
- Add meta data in head from theme
- Create New User Custom Field not Saving
- what is `get_section()` and how to use it?
- get_field() with ID in one signal filter not working
- Creating a “Related Meta” type field?
- Hide empty custom field
- Comment function for page
- Remove External Links from WordPress posts Using add_filter() in Theme functions.php
- How to echo the translated custom field?
- How to add function to custom fields when page/post has a password?
- How to exclude posts with empty and non-existent relational custom field with meta_query?
- Define an extra field for all pages (with no plugin?)
- wp_nav_walker that interacts with widgets to setup mega menu
- Allow tags and attributes in post and pages content
- Syling Custom Fields echo’s from from functions.php
- does acf_save_post cause endless loop?
- ACF Date fileds to Age Convert [closed]
- Why functions metaboxes is causing White Screen in Admin [closed]
- Getting error on function.php
- Update post meta with wp cron
- ACF number less than comparison not working