How to add dynamic list based on category

I want to know how I can show some list of related post when some one clicks one post.
for example when some one clicks on informatica post , it should show some particular list of post in right bar,
Informatica transformation
[lookup Transformation]
[Router transformation]
[Rank Transformation]
[Normalizer Transformation]

Informatica Admin

similarly if someone click post on oracle , then it should show oracle related post ( some main post which i want to show , not by plugin itself,

My site

If you are using a custom theme or child theme, you could add code like this to the page in question. It determines all the categories for the current post, and then finds the other posts in those categories.

<?php
$post = get_post();
if ( $post ) {
    // Get all the categories for the current post
    $categories = get_the_category( $post->ID );
    
    foreach ($categories as $category) {
        // Add a loop to get all posts for each of these categories
        $args = array(
            'cat' => $category
        );
        $my_query = new WP_Query( $args );
        
        // Display the titles of all posts with that category
        if ( $my_query->have_posts() ) {
            echo '<ul>';
            while ( $the_query->have_posts() ) {
                $the_query->the_post();
                echo '<li>' . get_the_title() . '</li>';
            }
            echo '</ul>';
        } else {
            // no posts found
        }
            
        wp_reset_postdata();
    }    
}

Thanks ., buts it technical for me… do we have plugin to enable it?

Yes there are plugins for it.

  1. Inline Related Posts
  2. Yuzo Related Posts
  3. Related Posts for WordrPress
  4. Contextual Related Posts
  5. Yet Another Related Posts Plugin

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.