Skip to content

Latest commit

 

History

History
25 lines (14 loc) · 1.09 KB

README.md

File metadata and controls

25 lines (14 loc) · 1.09 KB

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!