Bernhard
Member
Posted 1 year ago #
Hi,
I'm wondering that nobody asked this question before or that I didn't find it:
I'd like to have a Subheading by default if none is written.
I imagine something like:
<?php
if ( !is_front_page() && (function_exists('the_subheading')) && ( !is_empty('subheading')) ) { the_subheading('<h2>', '</h2>'); }
else { ?> <h2>default Subheading</h2>
<?php } ?>
Is there any possibility?
Hi,
This is possible using something similar to the following:
<?php
if (!is_front_page() && function_exists('the_subheading')) {
$subheading = the_subheading('', '', false);
if (!empty($subheading)) {
the_subheading('<h2>', '</h2>');
} else {
?><h2>Default Sub Heading</h2><?php
}
}
?>
You could have used the get_the_subheading function, but I spotted a bug with that!
Hope this helps :)
Bernhard
Member
Posted 1 year ago #
Hi,
Thank you very much for the fast support!
That works perfectly!