php - Next Previous Post in wordpress -
how can show content in next previous post of wordpress. example. next post link title there, possible show content of post (100 words).
<div class="alignleftfp"> <?php next_post_link('%link', '%title'); ?> <?php get_next_post();?> </div> <div class="alignrightfp"> <?php previous_post_link('%link', '%title'); ?> <?php get_previous_post();?> </div>
much appreciated if response. . .
if it's within loop, can use the_excerpt()
or get_the_excerpt()
depending on requirements.
if it's outside loop, can use function post excerpt post id:
function get_excerpt_by_id($post_id){ $the_post = get_post($post_id); //gets post id $the_excerpt = $the_post->post_content; //gets post_content used basis excerpt $excerpt_length = 35; //sets excerpt length word count $the_excerpt = strip_tags(strip_shortcodes($the_excerpt)); //strips tags , images $words = explode(' ', $the_excerpt, $excerpt_length + 1); if(count($words) > $excerpt_length) : array_pop($words); array_push($words, '…'); $the_excerpt = implode(' ', $words); endif; $the_excerpt = '<p>' . $the_excerpt . '</p>'; return $the_excerpt; }
hope helps!
Comments
Post a Comment