WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] One post exception to excerpt length... (6 posts)

  1. iamharlan
    Member
    Posted 4 years ago #

    Now here's one that probably hasn't been asked before.
    I run a multi-author blog that consists of several different types of articles. I am hoping to introduce a new weekly links post to the content, but I want the post to ignore the excerpt length requirements. Essentially, I want everything to be excerpted (if that's a word) and this post to show in its entirety every week. Is this possible?

    I though about maybe introducing a new category and creating a code that would call the content if it was in this category, but only the excerpt if it was in any other category. I think that will work, but alas, I am fairly new to php.

    Any help would be greatly appreciated.

  2. s_ha_dum
    Member
    Posted 4 years ago #

    You could do that with a category, a tag or a custom meta field. The category is probably the easiest.

  3. iamharlan
    Member
    Posted 4 years ago #

    Yeah, that's what I figured. But like I said, I'm still fairly new to php and wordpress tags. Can you give an example of the code that would make this possible?

  4. s_ha_dum
    Member
    Posted 4 years ago #

    Find your Loop, then find the the_excerpt function, and replace that with a switch like this one.

    if (in_category('myspecialcat')) {
     global $more;
     $more = 1;
     the_content();
    } else the_excerpt();
  5. iamharlan
    Member
    Posted 4 years ago #

    That worked perfectly. I was actually working with a truncated post instead of an excerpt, but it worked all the same. Thanks!

  6. iamharlan
    Member
    Posted 4 years ago #

    Hey guys...sorry to open this back up...but I'm wanting to do this again, but this time add an additional category to the mix. Basically, if it is in the "links" or "pages" category...I want the full post. Otherwise, I'd like the post to stay truncated.

    The current code I have in there is...

    <?php if (in_category('links')) {
                      global $more;
                      $more = 1;
                      the_content();
                      } else truncate_post(410, ""); ?>

    I've tried it a couple of ways, but what keeps happening is I get duplications of the truncated portions. I'm sure it's something really simple, but my brain is wracked trying to figure it out.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.