Thread Starter
YoChen
(@piedro)
Hello chinmoy!
I know this article. It doesn’t help with my questions.
I understand that I can change some of the <more>-appearnace issues with the “the_content” individually. But I don’t understand, as stated above, how to change the behaviour globally.
Also the article has no solution to the problem of having a “…” that is not a link and having the link text “read more” in a translateable form.
Any help?
thx,
piedro
Write the following code in your functions.php file:
<?php
function pwd_entry_post($number) {
$content = get_the_content();
$content = apply_filters('the_content', $content);
$content = preg_replace('@<script[^>]*?>.*?</script>@si', '', $content);
$content = preg_replace('@<style[^>]*?>.*?</style>@si', '', $content);
$content = preg_replace('|<img.*?src=[\'"](.*?)[\'"].*?>|i', '', $content);
$content = strip_tags($content);
$content = substr($content, 0, strrpos(substr($content, 0, $number), ' '));
echo $content;
echo "...";
echo "<a href='".the_permalink()."'">More</a>";
}
?>
And call the function “pwd_entry_post(1000)” form your template file(index.php).
Hope you want this type of functionality.
Thread Starter
YoChen
(@piedro)
hello chinmoy!
thx for your code!
I’m not sure yet whether that’s it because I have to admit I don’t really understand it exactly.
But I inserted your code in th functions.php.
Now in the loop:
below
<?php the_content() ?>
I place
<?php pwd_entry_post($number) ?>
But now I get:
Here is the content of my article,
goes further and further (more)
…http://www.mydomain.com/events/article-titel/More
(herein the “More” here is a link to
http://www.mydomain.com/events)
I tried to establish a version like
Here is the content of my article,
goes further and further …
More
Thread Starter
YoChen
(@piedro)
Oh forgot:
I had to take out the fourth ” in this line
echo "<a href='".the_permalink()."'">More</a>";
chnage to
echo "<a href='".the_permalink()."'>More</a>";
Was this incorrect on my part?
p.
Thread Starter
YoChen
(@piedro)
One more:
Maybe it’s not important to replace the more within the content.
I can replace “more” with “…” according to the article with the the_content('...')
And then use your function to have a second, css-styled “More”-Button underneath!
If you could just help me to use your pwd_entry_post($number)-function correctly … that would be very nice!
thx anyway,
piedro
Thread Starter
YoChen
(@piedro)
hello again!
I still don’t get the use of the
pwd_entry_post($number)
-function correctly working.
Obviously
<?php pwd_entry_post($number) ?>
doesn’t do the trick… plz help someone!
thx, piedro
<?php pwd_entry_post(400) ?>
400 means how many character show in the post. You can change this number.