Hi!
I have a static page and I want this page to show the latest 10 news with the specific tag "xxx". How can I do it?
Thanks
Hi!
I have a static page and I want this page to show the latest 10 news with the specific tag "xxx". How can I do it?
Thanks
Try creating a custom page template that contains a custom query based on get_posts or query_posts. Then apply the new template to your static page.
Create a Page Template and assign it to that static page, then use something like:
<?php
$args=array(
'tag__in' => array(3),
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => 10,
'caller_get_posts'=> 1
);
$my_query = null;
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) {
echo 'List of Posts';
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
<?php
endwhile;
}
wp_reset_query(); // Restore global post data stomped by the_post().
?>
Related:
Stepping Into Template Tags
Stepping Into Templates
Template Hierarchy
query_posts()
How do I determine a Post, Page, Category, Tag, Link, Link Category, or User ID?
This was fast! Thanks! I will try it...
Hi Michael! In your code where can I definie that the tag is "xxx"?
Read that last link I provided if you don't know the ID of the Tag you want displayed.
This topic has been closed to new replies.