igloobob
asked on
wordpress if / else for custom fields
Hello, I have a set of custom fields which are not always populated. I need to display them if populated and either display nothing or display a message if they are not.
This is the code to display the fields on the page.
So for the sake of figuring this out I'd like it to display the word 'unkown' if any of the fields are empty.
I know I need to be using an if / else but not sure how so can anyone please point me in the direction?
Thanks!
This is the code to display the fields on the page.
<h6><span>By: </span><?php yyy_authors(); ?>. <span>Updated on:</span> <?php yyy_date_updated(); ?>. <span>Document type:</span> <?php the_field('document_type'); ?></h6>
So for the sake of figuring this out I'd like it to display the word 'unkown' if any of the fields are empty.
I know I need to be using an if / else but not sure how so can anyone please point me in the direction?
Thanks!
ASKER
Hi it's actually using ACF for one of the fields but a different plugin for the other two (it's a private plugin pulling documents from external sources that I was supplied with as part of the job).
<?php yyy_authors(); ?>
<?php yyy_date_updated(); ?>
are the ones from the other plugin.
I tried your code above but it just returns 'unknown'
<?php yyy_authors(); ?>
<?php yyy_date_updated(); ?>
are the ones from the other plugin.
I tried your code above but it just returns 'unknown'
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
hi sorry for the delay, I've been on other jobs.
I spoke to the developer and he set it up to include get functions for the fields, it's a custom plugin that's still in development.
Thanks for the advice on that.
I spoke to the developer and he set it up to include get functions for the fields, it's a custom plugin that's still in development.
Thanks for the advice on that.
I'm assuming so because of the call to the function the_field(), the_field() returns false if no value is set.
Open in new window