Skip to content

One way to show your related posts on Wordpress, without using a plugin

Notifications You must be signed in to change notification settings

dormenique/relatedposts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

Related Posts

One way to show your related posts on WordPress, without using a plugin. Made for https://profanos.com

At the end of the page, it will display 4 related posts.

The category of each one, is not so specific, than I use a PHP code to always get the fist tag, other then the category posts.

$first_tag = $tags[0]->term_id;

But only if it has them

if( $my_query->have_posts() ) { echo '<div id="related_posts" class="clear"><h3>Posts Relacionados</h3><ul class="related_posts_container">';

They asked me if I could display these related posts in a more organized way, specialy with the mobile version. So, for the style, I called an object-fit: cover; on each cover img, following by this grid template, so the posts would respect the rule grid-template: auto/repeat(auto-fit,minmax(180px,2fr));

Desktop

image

Mobile

image

That's it!

About

One way to show your related posts on Wordpress, without using a plugin

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published