I have this exact thing working on a current project.
Here’s the code:
<div class="photo-feature" style="background: url(<?php the_field('the-image', $page->ID) ;?>) no-repeat center center; "></div>
Keep in mind a couple of things:
- You may need to use $post->ID or $page->ID if you’re using a custom query.
- Make sure you’re not overriding your background CSS anywhere else (use inspector to double check)
Finally – you should take the single quotes out of your inline CSS.
style: url(path)
not style: url('path')
Related Posts:
- Redirect to another page using contact form 7? [closed]
- Do something with thumbnail image on post publish
- How can I make add_image_size() crop from the top?
- Unable to check if plugin is active
- What plugin can I use to create a list / slideshow of featured images?
- How to get current post ID in Contact Form 7 wpcf7_before_send_mail hook action
- Prevent publishing the post before setting a featured image?
- Using Advanced Custom Fields with WordPress and Lightbox
- How to add meta box to plugin admin page?
- Modify featured image URL at runtime
- How to store ACF custom fields data in a custom table
- Generate Advanced Custom Fields box in custom admin menu page
- Edit Imported advanced Custom Fields from wordpress Dashboard
- Add custom meta box on Post page
- Validation Function for URL in plugin
- Creating Custom Meta Boxes on Plugin Option Page
- Visual Composer vs. Advanced Custom Fields [closed]
- ACF for audio url in wordpress audio shortcode
- How to attach Links into page/post or custom post type?
- Add post thumbnail from external image with plugin
- Can you use another Profile Builder shortcodes through advanced custom fields
- Add padding while generating thumbnail
- dirname( __FILE__) returning wrong directory inside plugin
- Show meta box only when post is being published first time
- Retrieving Meta from Image Attachment
- How to export all content with feature images?
- WordPress metaboxes – textfield suggestion automatically populated
- ACF: post query, hide duplicate values [closed]
- Paid Membership Pro with ACF [closed]
- Why are my queries interfering with the global post variable?
- Is there a best practice remediation for PhpStorm’s warning that void function the_post_thumbnail is used?
- ACF only showing up in Homepage but doesn’t appears in all pages
- Advanced Custom Fields – Disable Users to Edit Custom Fields
- Plugin to hide image in excerpt
- Finding the screen id of a page generated with add_menu_page
- Using ACF default value to autoincrement a number field
- URLs Added to ACF Repeater Field are not working
- Advanced Custom Fields – Get value in other plugin file [closed]
- Date format – Meta Box plugin
- Slashes stripped in ACF
- Meta Box by Rilwis, Load metabox on all page templates EXCEPT the homepage
- Cropping images from top center using Jetpack Photon
- Remove Advanced Custom Fields plugin for client?
- Adding class to last list item? Not WP generated
- Keeping and updating ACF and ACF Pro at the same time
- Adding custom meta boxes to specified custom post type
- How do we update a custom file upload field with the Advanced Custom Field plugin?
- Access post title from custom meta box on title change
- Add “Featured Image” box in my plugin post page
- Advanced Custom Fields (acf) – Filter Relationship by Taxonomies not Post Type
- Couple of beginner’s questions [closed]
- Inserting Plugins Into Blank Space of Externally Designed WordPress Theme
- ACF – How to set the menu order for the relationship field
- Scrape a webpage for image and add it to post
- Conditional custom redirect
- add_meta_box creating default form field types
- Should meta boxes for specific pages be save in their own plugins?
- Preview with Custom Post Type Not Working
- How to display a number of posts based on a Advanced Custom Field (ACF)
- Translation to ACF relationship field
- WordPress meta-box and checkbox-list
- How to get the get the select values created by ACF plugin in wordpress
- Advanced custom fields and Slideshow gallery desn’t work together? [closed]
- Adding featured image to posts created by a plugin
- Regenerate Thumbnails Plugin successfully updated my thumbnails but image src won’t change to new image size?
- Add_image_size not generating correct size
- Advanced Custom Fields Plugin – Images not displaying
- Multiple Post Thumbnails Plugin – Need help with code
- How to create repeater field manually, without plugin (ACF Pro)?
- Error Metabox Warning: call_user_func() expects parameter 1 to be a valid callback
- How to validate custom fields in Quick edit/bulk edit?
- What snippet do I need to type to show my ACF field show up on my theme?
- Replace the_content with ACF Flexible Content via function
- Custom Meta box change size
- How to hide featured images of all posts falling under the same category in wordpress?
- Revision featured image
- acf backend error handling
- Allow webp use on website but disallow webp as featured image during post creation
- Setting Author on CPT
- Upload Image with a file URL and show dynamically on Frontend
- Can’t load the the canges of field groups [duplicate]
- Preset custom fields
- submit two file input fields in the same form
- Multisite – Cloning CPT pages + content (including ACF Flexible Content) from site to site
- insert og image link in wordpress post
- ACF checkbox return format based on page
- WordPress default post categories meta box widget
- How to Add call button on a featured image in a wpsite? check the slap king image, there are two buttons on the featured image
- custom fields not displaying on wordpress site
- Display Multiple Photos as Featured Image when mouse moves on to it post
- ACF Fields are not showing up on Homepage
- Why Custom fields description is not working WordPress Version 5.4.2?
- Images are broken in Wysiwyg Editor – ACF backend
- Use AJAX to fetch Current Post Thumbnail for WordPress when Uploaded throughMedia Uploader Frontend
- make p tag collapsed after 3 rows
- How do I change the functionality of an image slider which is part of ACF?
- How to get checkbox by default true in metabox?
- automatically set random featured image by category in wordpress on post
- Import 2000 posts from one website to another
- Hide Featured Image in AMP