Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm building a portfolio site for a friend and he's got three seperate photo packages and may want to add more in the future, so I've created a custom post type called Packages so that he can add as many as he likes and they'd all appear on one page. I've created a single-packages.php template so that each package would link to a sinple.php page to show the full content, but when I add the 'more' tag within the editor it doesn't split the content and the packages page spews out everything rather than just showing the content before the 'more' tag.

Any help on this much appreciated.

note - I'm not a PHP expert and so won't understand complex coding suggestions

share|improve this question
2  
Shouldn't you be using <!--nextpage--> to paginate a post(custom type or post)?, the <!--more--> tag is behaving exactly how it should do if i'm not mistaken. –  t31os Aug 18 '11 at 17:57
    
+1 to t31os. Have a look at posts_nav_link: codex.wordpress.org/Function_Reference/posts_nav_link –  Steven Aug 18 '11 at 19:17
    
I'm not wanting to paginate the packages page. I want each package custom post type to show an extract and then link to the full content hence the need to create a single-package.php page that will display the full content. so I need the 'more' tag - but it's not working - I just get all the content rather than just an extract and a link with each package. –  Evie Milo Aug 18 '11 at 19:21
    
so thanks for the link - but I'm not looking for previous and next navigation - I'm looking for how to link to each separate package page –  Evie Milo Aug 18 '11 at 19:22
    
If you're viewing a single post(be it or custom post type or otherwise) you are essentially viewing that piece in it's entirety, the "more content" aspect simply shows a portion of that content on an archival view, ie. a view not single(that specific piece). Am i missing something? (please clarify if i'm not quite understanding).. –  t31os Aug 18 '11 at 20:53

2 Answers 2

In some situations, the $more global needs to be set to 0 before calling the_content() in order to show the read more link:

 global $more;
 $more = 0;
 the_content( '<span>Read More...</span>' );
share|improve this answer
    
It works like a charm! :D –  frabiacca Mar 29 '13 at 13:58

I've had the same problem and found this to be the best solution:

<?php
   $content = get_the_content(); 
   $dot = "."; 
   $position = stripos ($content, $dot); 

   if($position) { 
        $offset = $position + 1; 
        $position2 = stripos ($content, $dot, $offset); 
        $first_one = substr($content, 0, $position);
        $first_two = substr($content, 0, $position2); 

        if($position2 > 120) {
           echo $first_one . '.';
        }

        else {
            echo $first_two . '.';
         }
   }

         else {  

         }

?>

The code above displays two first sentences (the post excerpt) and if they are longer than 120 symbols - it will display only the first one.

If there are no dots in the content it does nothing.

Now just attach Read more link after your excerpt:

<a class="read-more" href="<?php the_permalink(); ?>">Read more...</a> 

And everything is fine.

I'm not sure why "more tag" doesn't work for some custom post types, but I spent a lot of time figuring it out and after all ended with this silly function.

I'm not a PHP programmer neither and I know this solution is pretty long and complex, but that's the only thing that worked for me and I was in the same spot.

The function isn't perfect and doesn't recognize dots after words like "etc." or "e.g.", it will treat every dot as sentence ending.

share|improve this answer
    
Hi there - I might give this a go asit might be the only solution, but I'd rather not be restricted by using an excerpt as I want to be able to type as much as I like and add the read more link wherever I need it to go, so that content doesn't get cut off mid sentence. –  Evie Milo Aug 19 '11 at 11:46

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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