Place 'read more' link in PHP code.
-
Hi Everyone,
I am relatively new to PHP and need help with the following. On the category pages there are a few except on each page. There is the title (which can be clicked to the full article), followed by the text excerpt of 35 words but it just cuts there. I want to add a read more at the end so readers can click that to read more. Here is the code without the ‘…read more’.
<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3> <?php ob_start(); the_content('Read the full post',true); $postOutput = preg_replace('/<img[^>]+./','', ob_get_contents()); ob_end_clean(); ?> <?php $excerpt = $postOutput; $order = array("<p>", "</p>"); $replace = ''; #$newstr = str_replace($order, $replace, $excerpt); #$newstr = strip_tags($newstr); $newstr = strip_tags($excerpt); echo '<p>'. string_limit_words($newstr,35) .'</p>'; ?>
Thanks in advance for your assistance.
J.
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Place 'read more' link in PHP code.’ is closed to new replies.