WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Is it possible to have (2) different exerpt lengths? (7 posts)

  1. Shaun Brown
    Member
    Posted 3 years ago #

    Curious, Is it possible to have (2) different excerpt lengths controlled via your functions.php template? ie. Currently, I am using

    function new_excerpt_length($length) {
    return 55;
    }

    to filter how many characters I want to show up for each post...however, what Id like to do is feature the excerpt much shorter in my "works" category in order to tailor it to my design. So is it possible to add yet another function in order to make it pass that set of arguments twice, but for different pages, categories, etc?

  2. chinmoy
    Member
    Posted 3 years ago #

  3. Shaun Brown
    Member
    Posted 3 years ago #

    Thanks, Ill check it out.

  4. alchymyth
    The Sweeper & Moderator
    Posted 3 years ago #

    try something like:

    function new_excerpt_length($length) {
    if(in_category('works')) return 25;
    	else return 55;
    }

    you could expand this with more (elseif) conditional statements.

  5. Shaun Brown
    Member
    Posted 3 years ago #

    Very cool, this is perfect.
    Hey Al - is it possible to replace the "in_category" to something that calls a "tag" instead? I know there is isnt an "in_tag", at least to my knowledge...so what could you use to accomplish the same task if its at all possible?

    Thanks again.
    -SB

  6. alchymyth
    The Sweeper & Moderator
    Posted 3 years ago #

  7. Shaun Brown
    Member
    Posted 3 years ago #

    Ouch man...lol. Yes, apparently I suck I finding the stuff I need though on occasion hence the beauty of the forums. Sorry if Im putting you out, I really appreciate the help though.

    -SB

Topic Closed

This topic has been closed to new replies.

About this Topic