Home › Forums › General Issues › Setting a function as a Default Field › Reply To: Setting a function as a Default Field
I’m reading between the lines here but I think you mean something like this:
<?php $custom_title = get_field('custom_title');
if( ! $custom_title ) { $custom_title = get_the_title(); } ?>
<h1><?php echo $custom_title; ?></h1>
So basically we say; if no custom field exists use the post title. It’s not the most detailed of questions but I’m hoping this is a suitable answer and helps you.
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.