- Advertisement -
Quickly use below guide to display related post in carrington mobile theme without plugin.
If you have noticed I have been providing tutorials on how to edit Carrington Mobile Theme the popular framework Naijaloaded Mobile theme is built with. Today on this guide I am going to show you how you can quickly edit carrington mobile theme to display related post inside the post content.
Follow the steps below to display related post in carrington mobile theme
1. Go through your wordpress dashboard and on appearance choose theme editor.
2. Select Carrington mobile theme as the theme you want to edit.
3. In this directory open the single.php file.
4. Search using CTRL + F for “cfct_content();” without the quotes and in the line after the code paste the below code.
?>
<?php
//for use in the loop, list 5 post titles related to first tag on current post
$tags = wp_get_post_tags($post->ID);
if ($tags) {
echo 'Related Posts';
$first_tag = $tags[0]->term_id;
$args=array(
'tag__in' => array($first_tag),
'post__not_in' => array($post->ID),
'showposts'=>5,
'caller_get_posts'=>1
);
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) {
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
<?php
endwhile;
}
}
?>
<?php
5. Click on Save and you are done.
Final Note: Hope you have seen how quickly you were able to achieve this. The reason is because I have simplified the process so that anyone that wants to customize carrington mobile theme will find it easy while going through this post. For now lets call it a day.