1

I'm not sure if this is even possible, but I thought I would ask anyway. I'm currently using a custom plugin that connects to my forums. If people are in a certain custom usergroup, they can see the full content of a post (the_content). If they're not, they only see the post's first 55 words (the_excerpt). You can see the abbreviated code here, which I'm using on my theme's single.php page:

   <?php // IN X USER GROUP
        if($customgroup==1 || // Are they in the custom group?
       $userinfo->usergroup == 66) { // or the admin of the website?
      echo the_content();
    } else { // They aren't in the custom group  
      echo the_excerpt (); 
    } 
    ?>

However, the_excerpt only allows me to show the first 55 words of the post to the non-X group members.

What I want to do is set exactly where the excerpt ends. That way, I can control what the non X-group members can see up to. I've tried using Wordpress's more tag to denote where the excerpt should end, but haven't had any success getting it to work. I've used it in combination with both the the_content and the_excerpt, but they both ignore it.

I'm not sure what I'm doing wrong. If I'm approaching this all wrong, what I just want to do is show the entire post to the X group members and show the excerpt I've denoted by the more tag to the non-X group members. Anyone have any ideas? Thank you!

4
  • Have you tried THIS? Commented Sep 1, 2013 at 18:02
  • I don't understand how that would accomplish what I'm trying to do. Can you explain?
    – Jon
    Commented Sep 1, 2013 at 18:29
  • adding more tag after the_excerpt()... Commented Sep 1, 2013 at 19:30
  • I don't think we're on the same page, lol..
    – Jon
    Commented Sep 1, 2013 at 20:03

1 Answer 1

2

first of all you don't need to echo the_content(); and the_excerpt(); both methods already echod, second simply put the more link using permalink after the_excerpt(); like this.

<?php // IN X USER GROUP
    if($customgroup==1 || // Are they in the custom group?
        $userinfo->usergroup == 66) { // or the admin of the website?
        the_content();
    } else { // They aren't in the custom group 
        global $more;
        $more = 0;
        the_content();
    } 
?>

Edited: added second param true to the_content('', true) this will cut off the content after <!--more--> quicktag.

6
  • I don't think we're on the same page; perhaps I'm not explaining myself well enough. I have no use for the "Read More" link. All I want is to show a specific excerpt to people who are not in X user group when they visit the news story's single.php page. Right now it shows the whole post to people in X user group and to everyone else, it needs to show an excerpt of the story that I've set using the more quick tag. I don't want to use its "Read More" link or anything - I'm only using the more quicktag to set where the excerpt ends for people not in X user group.
    – Jon
    Commented Sep 1, 2013 at 21:38
  • @user1445975 i have edited my answer, now replace this new code with old and let me know.
    – Anjum
    Commented Sep 2, 2013 at 9:14
  • This sort of works, but it only shows what's /after/ the more tag. In other words, it skips the excerpt and shows everything else, haha. Any idea how to reverse that to show only the excerpt and hide everything else? Thank you! :)
    – Jon
    Commented Sep 2, 2013 at 17:10
  • @user1445975 oh ok edited now try with new code
    – Anjum
    Commented Sep 2, 2013 at 17:31
  • You are an angel! That mostly did the trick. However, a "more..." link is now showing which leads to nowhere. Is there a way to remove it?
    – Jon
    Commented Sep 2, 2013 at 18:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.