WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] [Plugin: Subheading] default Subheading if is empty (3 posts)

  1. Bernhard
    Member
    Posted 3 years 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?

  2. Steve
    Member
    Posted 3 years ago #

    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 :)

  3. Bernhard
    Member
    Posted 3 years ago #

    Hi,

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

Topic Closed

This topic has been closed to new replies.

About this Topic