PHP elseif statement problem | WordPress.org

This works

<?php
if( get_field('divergence', 10681) ) {
	<div>Some text</div>
}
else
	echo '<div>' . "Some alternative text" . '</div>';
?>

But I want to use this method so the HTML isn’t echoed

<?php if( get_field('divergence', 10681) ): ?>
	<div>Some text</div>
	<?php elseif; ?>
	<div>Some alternative text</div>
<?php endif; ?>

I can’t get the else statement to work, only this works so far

<?php if( get_field('divergence', 10681) ): ?>
	<div>Some text</div>
<?php endif; ?>

I thought avoiding the echo method seems more appropriate when there’s a reasonable amount of HTML tags to use, as the above demo is simplified. Just want to place the tags as normal.

Thanks,



Source link