Quantcast
Channel: WordPress.org Forums » All Posts
Viewing all articles
Browse latest Browse all 112826

Junigo on "Place 'read more' link in PHP code."

$
0
0

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 all articles
Browse latest Browse all 112826

Trending Articles