Title: Place &#039;read more&#039; link in PHP code.
Last modified: August 20, 2016

---

# Place 'read more' link in PHP code.

 *  Resolved [Junigo](https://wordpress.org/support/users/junigo/)
 * (@junigo)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/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)

 *  [Marvel Labs](https://wordpress.org/support/users/royalprince/)
 * (@royalprince)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/place-read-more-link-in-php-code/#post-3151925)
 * Consider adding
 * </span>
 *  Thread Starter [Junigo](https://wordpress.org/support/users/junigo/)
 * (@junigo)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/place-read-more-link-in-php-code/#post-3151961)
 * Thanks Marvel Labs – I will try and let you know.
 * J.
 *  Thread Starter [Junigo](https://wordpress.org/support/users/junigo/)
 * (@junigo)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/place-read-more-link-in-php-code/#post-3151962)
 * This did not work. Any more suggestions?
 * J.
 *  Thread Starter [Junigo](https://wordpress.org/support/users/junigo/)
 * (@junigo)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/place-read-more-link-in-php-code/#post-3151963)
 * I got it solved. This is the code I added:
 * `<a href="<?php the_permalink(); ?>">...read more</a>`
 *  [AWN](https://wordpress.org/support/users/wakilnikzad/)
 * (@wakilnikzad)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/place-read-more-link-in-php-code/#post-3151993)
 * Hello dears.
 * I am using a WordPress theme called “Pinboard” in my [website](http://islampage.org)
   however it has a permalink in each post footer section but I want to add a “Read
   more…” link as well.
 * I tried adding above given code but it brings server error.
 * I fount the following code in my functions.php
 *     ```
       if ( ! function_exists( 'pinboard_excerpt_length' ) ) :
       /**
        * Change the number of words shown in excerps
        *
        * @since Pinboard 1.0
        */
       function pinboard_excerpt_length( $length ) {
       	if( pinboard_is_teaser() ) {
       		if( has_post_format( 'aside' ) )
       			return 36;
       		else
       			return 22;
       	} else
       		return 40;
       }
       endif;
   
       add_filter( 'excerpt_length', 'pinboard_excerpt_length' );
   
       if ( ! function_exists( 'pinboard_excerpt_more' ) ) :
       /**
        * Changes the default excerpt trailing content
        *
        * Replaces the default [...] trailing text from excerpts
        * to a more pleasant ...
        *
        * @since Pinboard 1.0
        */
       function pinboard_excerpt_more($more) {
       	return ' …';
       }
       endif;
   
       add_filter( 'excerpt_more', 'pinboard_excerpt_more' );
       ```
   
 * Please help me add a Read more link as well.
 * Thanks in advance.

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

The topic ‘Place 'read more' link in PHP code.’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 5 replies
 * 3 participants
 * Last reply from: [AWN](https://wordpress.org/support/users/wakilnikzad/)
 * Last activity: [13 years, 4 months ago](https://wordpress.org/support/topic/place-read-more-link-in-php-code/#post-3151993)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
