WordPress.org

Support

Support » Plugins and Hacks » [Resolved] [Plugin: Subheading] default Subheading if is empty

[Resolved] [Plugin: Subheading] default Subheading if is empty

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

Viewing 2 replies - 1 through 2 (of 2 total)
  • 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 🙂

    Hi,

    Thank you very much for the fast support!
    That works perfectly!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Resolved] [Plugin: Subheading] default Subheading if is empty’ is closed to new replies.