How to customize read more for every wordpress post

So many clients had requirement about customize read more link for every post. Tutorial for, How to customize read more for every wordpress post.

So achieving this functionality in easiest way is following.

Just add following code in your functions.php file.


<?php
//The Query
query_posts('posts_per_page=1');

//The Loop
if ( have_posts() ) : while ( have_posts() ) : the_post();

global $post;
$thePostID = $post->ID;
$custom_read_more = get_post_meta($post->ID, 'custom_read_more', true);

if ($custom_read_more) {
add_post_meta($thePostID, 'custom_read_more', 'You need to read this article');  //custom read more value
}

endwhile;
endif;
?>
customize read more for every wordpress post

customize read more for every wordpress post

Now you are set to use the custom read more value for each post. You need to just copy paste the following code in your index.php and page.php and single.php file.

<?php $custom_read_more = get_post_meta($post->ID, 'custom_read_more', true); ?>

<?php if (!$custom_read_more) { $custommore = 'Read More &raquo;'; } ?>

<?php the_content($custom_read_more); ?>

Add a Comment

Your email address will not be published. Required fields are marked *