Home › Forums › ACF PRO › Create a widget with ACF › Reply To: Create a widget with ACF
Hi
I am a little lost on this, even with the linked page above.
I too have created a custom widget within my theme which uploads an image to echo out onto the sidebar.
I’m not sure how to check if the image has been uploaded and then if so, display the image. Do I need to add the code(and change it to suit) in my functions.php file?
I added the following to my widget class:
if ( get_field('upload_image', 'widget_' . $widget_id); ) {
echo 'IMAGE!!';
}
Thanks in advance
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.