• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Display Excerpt instead of content in CPT archive with genesis_custom_loop

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › Design Tips and Tricks › Display Excerpt instead of content in CPT archive with genesis_custom_loop

This topic is: not resolved

Tagged: Excerpt, genesis_custom_loop

  • This topic has 4 replies, 2 voices, and was last updated 10 years, 5 months ago by simbasounds.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • January 23, 2015 at 3:44 pm #138459
    simbasounds
    Member

    Can I display the excerpt instead of the content in a CPT archive on a post-by-post basis?
    Perhaps this is a WordPress question, but since I'm using the genesis_custom_loop(), maybe there's a Genesis way?

    I have a custom archive for post-type called "charity". I need to check if the excerpt exists for each CPT post being queried (has_excerpt() function?), and then display the excerpt instead of the content in only those cases as it loops through them.

    The basic structure of my archive-charity.php looks like this:

    <?php
    remove_action( 'genesis_loop', 'genesis_do_loop' );
    add_action( 'genesis_loop', 'charity_do_loop' );
    function charity_do_loop() {
    	$query_args = wp_parse_args(
    		genesis_get_custom_field( 'query_args' ),
    		array(
    			'showposts'        => 999,
    			'paged'            => 0,
    			'post_type'      => array( 'charity' ),
    			'order' => 'ASC'
    		)
    	);
    
    	genesis_custom_loop( $query_args );
    }
    genesis();
    ?>
    http://simonbarnett.co.za/cycletour/charity/
    January 24, 2015 at 2:22 pm #138540
    Ren Ventura
    Member

    Genesis does this by default when the "Display post excerpts" option is selected from the Content Archive section (Genesis → Theme Settings).


    Web & Software Developer & Blogger | RenVentura.com | Follow Me on Twitter @CLE_Ren

    January 24, 2015 at 2:41 pm #138544
    simbasounds
    Member

    Hi Ren, thanks for replying.
    I no longer need this functionality on my current project, but it's worth clearing up for future reference.

    I already have Theme Settings set for normal post archives.
    What if I wanted different settings for CPTs?

    I imagine it would be something like the following in my CPT archive custom loop (although I don't recall if it worked or not):

    remove_action( 'genesis_entry_content', 'genesis_do_post_content' );
    add_action('genesis_entry_content', 'custom_content');
    function custom_content() {
        if (has_excerpt( $post->ID )) {
            the_excerpt();
        } else {
            the_content();
        }
    }
    January 24, 2015 at 3:19 pm #138549
    Ren Ventura
    Member

    Close. As written, that code would actually go outside the loop and you'd need to call the global $post since you're using it in the has_excerpt() conditional tag. However, has_excerpt() uses the current post if no arguments are passed so you can just leave it empty to have the same effect. But other than that, it looks good.


    Web & Software Developer & Blogger | RenVentura.com | Follow Me on Twitter @CLE_Ren

    January 24, 2015 at 3:22 pm #138550
    simbasounds
    Member

    Great : ) thanks
    Hopefully I'll get a chance to test-drive it soon..

  • Author
    Posts
Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘Design Tips and Tricks’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2025 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble