Answer the question
In order to leave comments, you need to log in
Wordpress + ACF - How to display the_title if the custom field is empty?
I need help from a knowledgeable php, I'm zero in it:
1. There is a standard page name <? php the_title (); ?>
2. I created a custom field in ACF to record another h1: <?php the_field( 'uslugi_header_h1' ); ?>
Question:
How to write a condition in php:
Display the field uslugi_header_h1. If this field is empty, then print the_title?
Answer the question
In order to leave comments, you need to log in
In short, an elementary condition, suddenly it will come in handy for the same baddies like me:
Here is the working code:
<h1 class="uslugi-head__h1">
<?php if( get_field('uslugi_header_h1') ): ?>
<?php the_field( 'uslugi_header_h1' );?>
<?php else :?>
<?php the_title(); ?>
<?php endif; ?>
</h1>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question