Related Posts are very used on single blog posts so lot of WordPress Themes have integrated this feature by default like Thype . In most of cases you haven't to use a plugin.
If you want to create a personalized related blog post element you can use this function with a specific WPQuery:
/** * Get related posts of post * @since 1.0.0 */ function codeless_get_related_posts( $post_id, $related_count, $args = array() ) { $terms = get_the_terms( $post_id, 'category' ); if ( empty( $terms ) ) $terms = array(); $term_list = wp_list_pluck( $terms, 'slug' ); $related_args = array( 'post_type' => 'post', 'posts_per_page' => $related_count, 'post_status' => 'publish', 'post__not_in' => array( $post_id ), 'orderby' => 'rand', 'tax_query' => array( array( 'taxonomy' => 'category', 'field' => 'slug', 'terms' => $term_list ) ) ); return new WP_Query( $related_args ); }
So the post that will show (as you see from the taxonomy) are from the same category.
Below you can find the code example on how you can use the function above to render the posts.
<?php /** * Blog Template Part for displaying single blog related posts * * @package Thype * @subpackage Blog Parts * @since 1.0.0 * */ $the_query = codeless_get_related_posts( get_the_ID(), 4 ); global $cl_from_element; $cl_from_element['is_related'] = true; // Display posts if ( $the_query->have_posts() ) : ?> <div class="cl-entry-single-section cl-entry-single-section--related"> <h6 class="cl-entry-single-section__title cl-custom-font"><?php echo esc_attr__( 'Related Posts', 'thype' ) ?></h6> <div class="cl-blog cl-blog--style-simple-no_content cl-blog--module-carousel"> <div class="cl-blog__list cl-items-container cl-carousel owl-carousel owl-theme" data-dots="1" data-nav="0" data-items="2" data-responsive='{"0": {"items":1}, "992": { "items":2 } }'> <?php $i = 0; while ( $the_query->have_posts() ) : $the_query->the_post(); if( has_post_thumbnail() ){ get_template_part( 'template-parts/blog/style-simple-no_content' ); $i++; } if( $i == 2 ) break; endwhile; ?> </div> </div> </div> <?php endif; wp_reset_query(); $cl_from_element['is_related'] = false; ?>
Now let check some WordPress theme that has this functionality native
Thype | Multi-Concept Blog & Magazine WordPress Theme
Thype is an incredibly versatile and surprisingly dynamic, aesthetically stunning, insanely versatile and also remarkably intuitive and also very easy to utilize and also reliable. Theme is customer-friendly receptive as WordPress magazine as well as a blog theme.
Fast-loading one-stop store service for a slew of varied website archetypes, firmly packaged with a host of hassle-free as well as powerful tools as well as plugins that make it possible for webmasters with no coding history to easily and also quickly create amazing, expert and ended up internet sites of all kinds.
If you desire to see what Thype is all around, have a look at one of their 20 spectacular multi-concept demos, or the online sneak peek function. It has considerable scalability and works well with reduced as well as moderate traffic sites.
StuffPost – Professional News & Magazine WordPress Theme
StuffPost is very neat and also comes with a full-size homepage slider that makes the theme appearance extremely professional. The homepage can display as a highlighted category magazine grid.
The theme likewise includes a responsive layout for mobile phones, making it much easier for mobile individuals to buy items from your website.
These kinds of themes typically can be made use of for a variety of different objectives such as for creating service websites, blogs, landing pages and so forth.
For instance in portfolio single web page you have choice to present the portfolio photos as slider, sliding slider, 2d slider, serial pictures, fullwidth image, image on right, picture on left,. The actual blog and also blog pages of the design template are placed on a semi-transparent background simply like the menu on the homepage. It is a fantastic and modern service for a recently constructed apartment or condo complicated, workplace facility or lease residence.
Folie | The WordPress Website Builder
Folie is a trendy, responsive, multipurpose theme that is flexible sufficient to work well for nearly any kind of website. It has a drag and also drop page builder that enables you to arrange theme modules and also design an interesting homepage. Folie allows you to develop one page or multipage website. There is an actually functional as well as abundant WordPress store theme created to be utilized with the WooCommerce plugin.
You have many options to show your post, you can merely switch over between blog designs:
- Parallax
- Homepage Fullscreen
- Grid
- Masonry
- Solitary Slider
- Single Pictures.
AMP assistance for WordPress bargain functions and also most important manuscripts, which can offer you added search engine optimization benefits as well as make your mobile web pages quickly as the speed of light. Light and also Clear menu bars are provided, along with an Ajax portfolio attribute.
Folie has been made to be a smart as well as powerful remedy to modern website structure needs, a qualified and also competent website design template.
Theme can be easily as well as easily adapted to a variety of different usages, owing to its tidy as well as immaculate designs.
Demos are extremely adjustable with very little effort allowing you to create finished and professional-looking pages in a matter of minutes.
Amos – Creative WordPress Theme for Agencies & Freelancers
Amos is great for Portfolio, Photographer , Designer , Freelancer , Architects , Online Store or anyone else who wants to showcase their works in a creative and beautiful way. It is equipped with lots of important features. Amos looks perfectly responsive on every device including Google AMP for single posts.
You can set up your online store with Amos ready-made WooCommerce template. Amos contains more than 50 content blocks to provide all the things you need to build a unique website in minutes without having any knowledge in coding.
It comes also with free and premium plugins included and compatible like: Visual Composer, Yellow Pencil, Revolution Slider, Layer Slider, Visual Composer, WPML, etc.
TheGem – Creative Multi-Purpose High-Performance WordPress Theme
TheGem is a versatile, responsive, high-performance WordPress theme with a modern creative design to suit a multitude of creative uses for building websites. Designed and developed as an ultimate web building toolbox of design elements, styles & features.
TheGem will help you build an impressive, high-performance website in minutes, without touching a line of code. It has over 40 unique multi-purpose design concepts, 150 stunning demo pages, eight navigation settings in over 20 styles, plus flexible page layouts.
This theme covers the need of any freelancer, photographer, architect, corporate business of any size and purpose, creative agency, etc. It supports both multi page and one page website approaches.
Specular – Responsive Multi-Purpose Business Theme
Specular you will find not only home variations or demos but fully created sites for you ready to publish online. There are more than 20+ ready to use sites created with research and dedication.
Specular provides unlimited layout customizations. With easy to use theme options, you can create a unique and perfect page for any purpose.
You can create more than 200+ layouts and unique styles like no other theme ever created.
It is fully responsive so no matter if you are in tablet, mobile or desktop, it looks awesome everywhere.
It is WooCommerce compatible so you can create your online shop and sell your products. The theme is compatible with WooCommerce Plugin
Specular is optimized for high resolution displays. All icons are font icons and is used the latest guidelines for css.
Ludjon, who co-founded Codeless, possesses a deep passion for technology and the web. With over a decade of experience in constructing websites and developing widely-used WordPress themes, Ludjon has established himself as an accomplished expert in the field.
Comments
I have set my posts to display recent posts from the post category. When I have a post with more than one category, I get 2 instances of recent posts. Is there a way to tell the plugin to limit to the first category instance? thanks!