Have you looked at using the WordPress categories for this. If you use categories, then use the Category Widget, when users click on one of those category links, they will see a display of the posts belonging to that category.
Related:
Category Templates
If you don’t want to use the category archive ability:
http://wordpress.org/extend/plugins/list-category-posts/
A page of posts example
Thank you MichaelH
the page of posts example seems to be what i am looking for. but where do i save the pageofposts.php file?
in the wp-admin folder, or outside, or on some other folder?
oh no…
it seems that the page now appears on the main header. and further, it does not attach posts based on the categories. it just displays the test data.
it now shows as:
Home “test page” Links Contact
the test page should not be displayed anywhere as a heading!!!
What am i doing wrong??
this is the code i used for page of posts. very little changed:
<?php
/*
Template Name: PageOfPosts
*/
get_header(); ?>
<div id="content" class="narrowcolumn">
<?php
// page id 112415 will get category ID 3347 posts
if (is_page('112415') )
{
$cat = array(3347);
}
else {
$cat = '';
}
$showposts = -1; // -1 shows all posts
$do_not_show_stickies = 1; // 0 to show stickies
$args=array(
'category__in' => $cat,
'showposts' => $showposts,
'caller_get_posts' => $do_not_show_stickies
);
$my_query = new WP_Query($args);
?>
<?php if( $my_query->have_posts() ) : ?>
<?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
<?php
//necessary to show the tags
global $wp_query;
$wp_query->in_the_loop = true;
?>
<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
<small><?php the_time('F jS, Y') ?> <!-- by <?php the_author() ?> --></small>
<div class="entry">
<?php the_content('Read the rest of this entry »'); ?>
</div>
<p class="postmetadata"><?php the_tags('Tags: ', ', ', '<br />'); ?> Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?> <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></p>
</div>
<?php endwhile; ?>
<?php else : ?>
<h2 class="center">Not Found</h2>
<p class="center">Sorry, but you are looking for something that isn't here.</p>
<?php get_search_form(); ?>
<?php endif; ?>
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
You should be saving that as a Page Template, for example pageofposts.php, then in a Page refer to that Template under the Attributes module.
Also see: How do I determine a Post, Page, Category, Tag, Link, Link Category, or User ID?
i saved it as pageofposts.php under the themes. but i’m not sure how to refer to that template.
and i’m sorry for such a stupid question but which is the attributes module?? i only have titlt attributes thats present in the “all in one SEO pack”
further, as mentioned in the code i created a test page of id 112415 and tried to include all posts under the categoryID 3347. however only the initial test data can be seen and none of the posts.
am i not doing something here??
i finally figured out where the attributes module was. but it shows only parent and order. nothing about templates. how do i get the template to come there??
i saved it as pageofposts.php under the themes
That template belongs under themes/your_theme_folder so for the WordPress Default theme you would put the template in the wp-content/themes/default folder.
Related:
Why is there no Page Template option when writing or editing a Page?
MichaelH, Thanks Loads. i managed to get all the posts required and arranged. one small snag though.
is there any way to publish only selected data/text of the posts description? i mean no html tags in the post description need to be displayed. is there any way to read and display posts so that the content in the “< .. > ” tags are avoided?
ps: can i display the data i give in the custom fields as well using this method?? what is the code i need to use?
is there any way to read and display posts so that the content in the “< .. > ” tags are avoided?
Not sure what you are talking about. In a “standard” post loop, $post->post_content will contain the post content.
Also, see Custom Fields
ok. i get it… It was something stupid i was doing while i was posting..
The problem has been solved.
Thanks a lot MichaelH.. Thanks for all your help.