Displaying an ACF field only if it exists

Viewing 4 posts - 1 through 4 (of 4 total)
#167263

ken nawrocki
Participant

We have purchased the WPDM – Advanced Custom Fields plugin and are atempting to add another button to the link-template default template. It works fine when I add the shortcode as such as click here. But if the link does not exist I do not want to show the button. So I tried this :
$l= trim(do_shortcode(‘[acf_AnotherDownload_buttonlink]’));

if( $l != ”){
echo’ Online Form‘;
}

This does not work. I also see there is a php snippet we could used
<?php echo wpdm_acf([ID],’AnotherDownload/buttonlink’); ?>, however to use this you need to id of the download and as mentioned elsewhere in this forum, get_the_id() does not work. I played around trying to get the current download id inside of the template, but was unable to get it in any reliable manner.

So is there a way i can use conditionals inside of template with the ACF shortcodes, or is there a way I can get the current id of the download inside of the template?

thanks
Ken

  • This topic was modified 2 years, 3 months ago by ken nawrocki. Reason: add code tags
#167274

Nayeem Riddhi
Moderator

Hello Ken,

Hope you are well. Can you please elaborate on your add another button to the link-template requirements please, I hope I can help you on the issue. Or you can also elaborate on the requirements with the ACF add-on too. please let me know

Thank you and regards

#167348

ken nawrocki
Participant

Hi Nayeem, thanks for your quick response.

What we are trying to do is add an additional download button to the default link-template. This link would be to a form on another part of the website and would not be a download. However we don’t need that link on every download listing, but only on certain downloads.

We have both ACF and the WPDM – Advanced Custom Fields installed and activated. I have created a field group which allows me to add a link to each download page. So if that link field has been filled out we would like to display the button and link the button to the link in the custom field. But if the link is not filled out, we do not display the button.

thanks
Ken

#167455

Nayeem Riddhi
Moderator

Hello Ken,

Sorry for some late. Can you please share the URLs of related files? if possible, please, give your temporary wp-admin login details in a private reply for checking the issue.

Thank you and regards

Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘Displaying an ACF field only if it exists’ is closed to new replies.