Support » Theme: Quark » Utilize Custom Excerpts and Default Excerpts

  • Resolved rezon8dev

    (@rezon8dev)


    Hi Anthony,
    I’m aware that category archives will display an excerpt if I use the more tag but what I need to do is:
    1) display a custom excerpt if there is one
    2) utilize the default excerpt from WordPress
    3) have the more tag available when I want it to be shorter than the default

    I found some code you provided here: https://wordpress.org/support/topic/page-with-posts-2?replies=7

    which uses an if statement in content.php calling the_excerpt but it did not work for me. Can you take a look and let me know if this should be working for what I’m trying to do?

    Just to be clear inside content.php in my child theme I replaced:

    <?php the_content( wp_kses( __( 'Continue reading <span class="meta-nav">→</span>', 'f4d' ), array( 'span' => array(
    					'class' => array() ) ) )
    					); ?>

    With:

    <?php if ( has_excerpt() ) {
       the_excerpt();
    } else {
       the_content( wp_kses( __( 'Continue reading <span class="meta-nav">→</span>', 'f4d' ), array( 'span' => array( 'class' => array() ) ) ) );
    ?>
    }

    My parent theme is called f4d…

    Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • BTW, the f4d them is Quark it was just renamed to f4d…

    Theme Author Anthony Hortin

    (@ahortin)

    It looks like I made a slight mistake with that code I wrote in the other post. The closing php tag (?>) should be after the last curly brace. So try this…

    <?php if ( has_excerpt() ) {
       the_excerpt();
    } else {
       the_content( wp_kses( __( 'Continue reading <span class="meta-nav">→</span>', 'f4d' ), array( 'span' => array( 'class' => array() ) ) ) );
    }
    ?>

    Hi Anthony,
    I actually solved this by adding is_archive to the code above which displays the excerpt for search results pages. like this:

    <?php if ( is_archive() || is_search() ) { // Only display Excerpts for archives and Search ?>
    			<div class="entry-summary">
    				<?php the_excerpt(); ?>
    			</div> <!-- /.entry-summary -->

    This seemed to do exactly what I was after.

    Thanks for helping, and by all mean if you see issue with this please let me know.

    Theme Author Anthony Hortin

    (@ahortin)

    Looks good. Glad you got it sorted 🙂

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Utilize Custom Excerpts and Default Excerpts’ is closed to new replies.