Display excerpts for specific CPT archives

Community Forums Forums Design Tips and Tricks Display excerpts for specific CPT archives

This topic is: not resolved

Tagged: , ,

This topic contains 4 replies, has 2 voices, and was last updated by  robkhoo 8 months, 4 weeks ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #75332

    robkhoo
    Participant
    Post count: 5

    Hi guys,

    Wondered if anybody could help out.

    My website currently displays a content limit of 300 characters on all of my archive pages.
    Whereas this is fine for blog archives, I would like something different for my job and classified archives. The jobs CPT is “jobs” and classifieds is “classifieds”. I’d like to have it so that if an excerpt exists, for the archive to pull that rather than the default content limit.

    Any tips or ideas here would be fantastic!

    Thanks

    Robert

    http://nagoya-info.com
    #75334

    braddalton
    Participant
    Post count: 9194

    If you look in the News Pro themes front page template you’ll see code which you can use in your CPT archive template and modify.


    Specializing In StudioPress Child Theme Customization.
    500+ StudioPress Tutorials

    #75335

    robkhoo
    Participant
    Post count: 5

    Hi Brad,
    Unfortunately I don’t have the NewsPro theme. Do you mean to get it from the source code on the theme demo page?

    Thanks

    #75572

    braddalton
    Participant
    Post count: 9194

    You could also use PHP code to control the limit for a CPT. http://my.studiopress.com/snippets/post-excerpts/

    Then add a conditional tag after the function:

    [php]
    add_filter( ‘excerpt_length’, ‘sp_excerpt_length’ );
    function sp_excerpt_length( $length ) {
    if ( is_post_type_archive( ‘portfolio’ ) ) {
    return 50; // pull first 50 words
    }}
    [/php]

    Untested. Change portfolio to the name of your CPT.


    Specializing In StudioPress Child Theme Customization.
    500+ StudioPress Tutorials

    #75586

    robkhoo
    Participant
    Post count: 5

    Hi again Brad,

    Thanks for the reply.

    Ok, I think I’m starting to understand a little more about how the functions and actions work.
    I’ll give this a try and let you know how it goes.

    Thanks again.

    Rob

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.