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 [email protected]
- The topic ‘Read More Conditional?’ is closed to new replies.