• I have a function for my GeneratePress child theme in functions.php that adds a <i>post’s</i> excerpt below its title.

    I need to do the same thing for <i>pages</i> using generate_after_page_title. (I already have a function to activate excerpts in pages.)

    Here’s the function for <i>posts</i>:

    add_action( 'generate_after_entry_title', 'generate_post_meta' );
    function generate_post_meta()
    {
    	if ( 'post' == get_post_type() ) : ?>
    		<?php if (function_exists('has_excerpt') && has_excerpt()) { ?>
    			<div class="intro-excerpt">
    			<?php echo get_the_excerpt(); ?>
    			</div>
    		<?php } ?>
    	<?php endif;
    }

    What do I need to do differently for pages (beyond changing the hook and function names, of course)?

    Thanks!
    Mark

Viewing 1 replies (of 1 total)
  • Hi @markroth,

    You’ll have to change this line as well.

    if ( 'post' == get_post_type() ) : ?>

    This condition basically checks if the page is a post page.

    Static pages are of page post type so you’ll have to change the 'post' type to 'page'.

Viewing 1 replies (of 1 total)
  • The topic ‘Adding Excerpt Below Page Title’ is closed to new replies.