customize read more for every wordpress post

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); ?>

Published by

Purab

I am Purab from India, Software development is my profession and teaching is my passion. Programmers blog dedicated to the JAVA, Python, PHP, DevOps and Opensource Frameworks. Purab's Github Repo Youtube Chanel Video Tutorials Connect to on LinkedIn

Leave a Reply

Your email address will not be published.