List of tagged posts on static pages? (4 posts)

  1. kaleksic
    Posted 8 years ago #

    I would like to list posts having a certain tag on pages, something similar to author posts.

    The ideal would be to have x most recent posts with tag y and a link to the tag page listing all posts with the specified tag.

    Is there any ready made code/plug-in for this or could anyone give me a hint how to do this?


  2. MichaelH
    Posted 8 years ago #

    If you use the WordPress Default 1.6 theme, you will see posts on displayed with the tags. When you click on a tag, it takes you to the tag archive automatically--that's the WordPress native ability to handle archives.

    Not sure if that answers your question so will also say that you can use the template tag, query_posts() (see the Tag Parameters and Combining Parameters sections), to present a page of posts that match your criteria.

  3. kaleksic
    Posted 8 years ago #

    Ok, thanks for the reply but it still didn't solve my problem.

    To detail a bit more what I was hoping to achieve:

    I would like to have static pages (the ones that I write, in my site e.g 'Dogs') display in the body of the page a short list of posts tagged with the page-slug (dogs). if there is no tag that corresponds with the page_slug it should just not display anything. I think it would be ok to just display the titles clickable.

    Now, since I am only semiliterate in php I don't want to spend a lot of time reinventing the wheel. I was hoping someone had already done this or could maybe point me to a plug-in that could do something like this.

  4. galveston
    Posted 8 years ago #

    Is this what you mean? This lists ALL posts with the tag=elaine, I am trying to figure out how to list, say 5 at a time and the n next>>

    		query_posts('tag=elaine'); ?>
    		 <?php while (have_posts()) : the_post(); ?>
    		 <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php _e('Permanent l&auml;nk till'); ?> <?php the_title(); ?>"><?php the_title(); ?></a></h2>
             <?php the_excerpt(); ?>
    		 <span class="post-cat">Skrivet:</span> <span class="post-calendar"><?php the_time('d F, Y') ?>.
             <?php the_tags(); ?>
    		 <?php endwhile;?>

Topic Closed

This topic has been closed to new replies.

About this Topic