Title: Read More Conditional?
Last modified: August 18, 2016

---

# Read More Conditional?

 *  Resolved [badrad](https://wordpress.org/support/users/badrad/)
 * (@badrad)
 * [20 years, 6 months ago](https://wordpress.org/support/topic/read-more-conditional/)
 * First, a quick thanks to everyone working on WordPress. It is my first time using
   it, and it is hands down the most well written, powerful piece of web software
   I have ever used. Its amazing how it balances being easy to use and completely
   extensible.
 * Anyway, I am using <!–more–> to show only the first part of a post on the index
   and in the archives. I use strip_teaser to strip the teaser off and show my own
   click here for more link, as it appears in the postmetadata section.
 * What I want to do is be able to post short entries that do not use the <!–more–
   > functionality. But for those shorter entries, I don’t want the text to be “
   Read More”, I want to be able to say something like “End of Post, click for permalink”
   or “permalink” or whatever I want.
 * SO, what I want is a conditional for if the <!–more–> functionality is being 
   used or not. So I could say
    ` if (use_read_more == true) { echo 'Fancy Read 
   More link'; } else { echo 'End of Article, Permalink'; }  or something along 
   those lines.
 * From what I can tell, there is no built in way to do this. So, please correct
   me if I am wrong.
 * I did come up with my own way. It increases the page load time on the index page
   by like .05 seconds, so tell me if you can think of an easier way to do it.
 * `
    <?php // lets see if there is a moretag or not
 * // start buffer
    ob_start();
 * // output post
    the_content('uniquestringoftext234hhk32lh432hlk3', true);
 * // empty buffer and capture contents
    $moretest = ob_get_contents(); ob_end_clean();
 * // lets see if our unique string was present
    $moreresult = strstr($moretest,'
   uniquestringoftext234hhk32lh432hlk3');
 *  if (empty($moreresult)) {
    /* do whataver I want for permalinks */ } else { /*
   do wahtever I want for read more links */ } ?>
 * So, my question is if there is a built in way to do this, and if not, can anyone
   think of a more efficient way then what I am doing?
 * Thanks in advance! Feel free to email me at [badrad@gmail.com](https://wordpress.org/support/topic/read-more-conditional/badrad@gmail.com?output_format=md)

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [Kafkaesqui](https://wordpress.org/support/users/kafkaesqui/)
 * (@kafkaesqui)
 * [20 years, 6 months ago](https://wordpress.org/support/topic/read-more-conditional/#post-288039)
 * First I’d suggest dropping the use of an output buffer; there’s ways around that
   in WordPress when dealing with the $post object. In any case, here’s a suggestion
   for a more efficient method (and with far less code):
 * `<?php
    the_content('Fancy Read More link'); if(!strpos($post->post_content, '
   <!--more-->')) : ?> End of Article, <a href="<?php the_permalink(); ?>">Permalink
   </a> <?php endif; ?>
 * This runs the_content() as normal, then checks to see if the <!–more–> quicktag
   exists in the post’s content; if not it adds the permalink (as it assumes a “
   shorter” post has just been displayed). That’s really all you need.
 *  Thread Starter [badrad](https://wordpress.org/support/users/badrad/)
 * (@badrad)
 * [20 years, 6 months ago](https://wordpress.org/support/topic/read-more-conditional/#post-288045)
 * Very cool. I knew there had to be a way to access the post contents without using
   the template tag that was requiring me to use output buffering, but I am still
   getting the hang of wordpress 🙂
 * Now I know I can directly access stuff in the $post array.
 * Using the new method, there is almost no increase in processing time, versus 
   a big one otherwise. Thanks a lot!
 *  [joshuaone](https://wordpress.org/support/users/joshuaone/)
 * (@joshuaone)
 * [20 years, 4 months ago](https://wordpress.org/support/topic/read-more-conditional/#post-288628)
 * All I want to do is add a permalink button at the end of each post (rather than
   being satisfied with the title as the permalink). Kafkaesqui, it looks to me 
   like the code you wrote above may be close to what I need. Would you please have
   pity on my non-geek brain on tell me what code I need to do that — and where 
   to put it. I would be grateful.
 *  [Kafkaesqui](https://wordpress.org/support/users/kafkaesqui/)
 * (@kafkaesqui)
 * [20 years, 4 months ago](https://wordpress.org/support/topic/read-more-conditional/#post-288629)
 * joshuaone, the code above is far more than what you need. To provide a permalink
   at the end of each post, just do something like:
 * `<?php the_content(); ?>
    <div class="permalink"><a href="<?php the_permalink();?
   >">Permalink</a></div>
 * You can use the .permalink class I gave to the div to style the link and it’s
   placement in your style.css. To use an image (i.e. button) instead of a text 
   link, change `Permalink` to `<img src="permalink.gif" alt="Permalink" />` — making
   sure your src attribute points to the image and it’s correct location on your
   site, naturally.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Read More Conditional?’ is closed to new replies.

## Tags

 * [custom](https://wordpress.org/support/topic-tag/custom/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 3 participants
 * Last reply from: [Kafkaesqui](https://wordpress.org/support/users/kafkaesqui/)
 * Last activity: [20 years, 4 months ago](https://wordpress.org/support/topic/read-more-conditional/#post-288629)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
