Hello World! Today Innovative is here to add some function to post and make them like tender to shuffle between posts and limit posts to the Specific category with the title.
WordPress FunctionsΒ used:
# get_adjacent_post
# get_permalink
# get_the_category();
#Β $prev_post
# $next_post
# my_custom_post_navigation
Steps to limit posts to the Specific Category with the title:
1. Go to your theme single.php [Some theme have template parts so try to find the exact location]
in my case I was working with Flatsome WordPress Theme, So itβs directory is {Public_html/wp-content/themes/template-parts/posts/content-single.php}.
2. Copy Paste the below code to content-single.php.
< div class="post-limited-navigations"> < /div>
3. Call the code in function.php of theme
/** * Return only the first category when outputting the previous/next post links */ function my_custom_post_navigation($terms, $object_ids, $taxonomies, $args){ return array_slice($terms, 0, 1); }
4. Add the style to [Apearance>Customize> Additional Css>]
.post-limited-navigations a { width: 50%; background: whitesmoke; text-align: center; border-right: 1px solid #000; border-left: 1px solid #000; padding: 20px 0px; font-size: 18px; font-weight: bold; }
Results
Thatβs it!
Hope you have liked the simple tutorial, Donβt forget to comment and share your information in the comment box. I will try my best to give response asap.
Wish you Best of luck!