Hello, I am able to show the title of the Next and Previous posts using this code:
Now I want to be able to show the Title, Image of post and an excerpt of the next or previous posts as seen in the image below:
.
How do I go about it? Thanks in advance
- Code: Select all
<cms:php>
global $CTX;
$page_ids = explode( ",", "<cms:pages ids_only='1' />" );
$cur_page_id = "<cms:show k_page_id />";
$pos = array_search( $cur_page_id, $page_ids );
if( $pos!==FALSE ){
if( $pos>0 ){
// Prev page id
$prev_page_id = $page_ids[$pos-1];
$CTX->set( 'prev_page_id', $prev_page_id, 'global' );
}
if( $pos<count($page_ids)-1 ){
// Next page id
$next_page_id = $page_ids[$pos+1];
$CTX->set( 'next_page_id', $next_page_id, 'global' );
}
}
</cms:php>
<cms:if prev_page_id >
<cms:pages id=prev_page_id skip_custom_fields='1'>
<a href="<cms:show k_page_link />"><i class="fa fa-angle-left"></i> <cms:get_custom_field 'text_for_previous_article' masterpage='globals.php' /></a>
</cms:pages>
</cms:if>
<cms:if next_page_id >
<cms:pages id=next_page_id skip_custom_fields='1'>
<a href="<cms:show k_page_link />"><cms:get_custom_field 'text_for_next_article' masterpage='globals.php' /> <i class="fa fa-angle-right"></i></a>
</cms:pages>
</cms:if>
Now I want to be able to show the Title, Image of post and an excerpt of the next or previous posts as seen in the image below:
.
How do I go about it? Thanks in advance