I have a WordPress blog (local installation) and I'm trying to add the following functionality to it:

Suppose I have a page on my blog entitled "Algebra", I want this page to contain a list of links to every post blog that has the tag "algebra" attached to it. For example, I make a post entitled "Quadratic Equations" and tag it under "algebra", currently I go to the "Algebra" page and add a link to my "Quadratic Equations" post. I would like to make this process automatic.

How can I do that? I couldn't find any plugin to do this.



If you place the code below in single.php file anywhere you want the links to appear in your posts, or inside a function in functions.php and the function tied to a filter or an action like 'the_content', the you shold get a list of links to the posts that have the same tag or tags as the post you are currently reading.

 global $post;
    $this_post_tags_ids = wp_get_post_tags( $post->ID, array( 'fields' => 'ids' ) );

    $query = new WP_Query( array('post_type' => 'post', 'posts_per_page' => -1, 'tag__in' => $this_post_tag_ids ) );
    if ($query->have_posts()){
          echo the_title('<h3><a href="'.get_the_permalink.'"/>', '</a></h3>');


I didn't tested it, but it should work.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.