Support

Account

Home Forums General Issues Setting a function as a Default Field

Solved

Setting a function as a Default Field

  • Hi, is it possible to set a function as a default field with acf?
    Example: get_the_title().

  • 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.

  • @morgyface Thanks, that’s exactly what I meant.

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

You must be logged in to reply to this topic.