chris2006
Member
Posted 3 years ago #
Hi,
I'm currently creating a number of wordpress informational pages, and would like to attach a number of post entries at the bottom of the page.
Is this possible?
Ideally i would like to attach posts from specific tags, does anyone know of any plugins that would achieve this?
Example:
Page about Blue Widgets
blue widget information here etc
Posts:
Blue Widgets Are Fun And Cool
New Blue Widgets Are Now Available
taffeljohan
Member
Posted 3 years ago #
I don't know of plugins for this, but it is pretty easy to put in a template, just by creating your own loop at the bottom. Something like this is all you need:
<?php
$myTaggedPosts = new WP_Query();
$myTaggedPosts->query('tag=chocolate');
?>
<ul>
<?php while ($myTaggedPosts->have_posts()): $myTaggedPosts->the_post();?>
<li><a href="<?php the_permalink();?>"><?php the_title();?></a></li>
<?php endwhile;?>
</ul>
chris2006
Member
Posted 3 years ago #
That's a great help thanks taffeljohan!
what would be a good solution to achieving this for multiple pages - with multiple tags?
Using conditionals for the pageID?
taffeljohan
Member
Posted 3 years ago #
Sounds like a plan, if there aren't too many. Otherwise it will be a pain to hard code everything. Otherwise you could use custom fields on the pages to store parameters (tag names, for instance).
By the way, it should have been
$myTaggedPosts->query_posts('tag=chocolate')
(i left out the _posts part)
taffeljohan
Member
Posted 3 years ago #
I take back that last correction! There is no query_posts method in WP_Query. I was right the first time.
gr33nturk
Member
Posted 3 years ago #
Thanks. Ill give that a try at http://lime.wire-2008.com