adamstruth@yahoo.com
Member
Posted 2 years ago #
Hi everyone.
Thanks for reading, I am a relatively new user to wordpress.
I am looking to show posts by a specific category on a page (the page has a custom template, the template code is shown below). All help much appreciated.
<?php
/*
Template Name: meetings
*/
?>
<?php get_header(); ?>
<div id="content" role="main">
<div id="mainContent">
<div class="post">
<h2>Meetings</h2>
<p>All posts under meetings</p>
</div>
</div>
<?php include("sideNav.php"); ?>
</div>
<?php get_footer(); ?>
You need to add a loop and add a function called query_posts().
Try:
<?php
/*
Template Name: meetings
*/
?>
<?php get_header(); ?>
<div id="content" role="main">
<div id="mainContent">
<div class="post">
<h2>Meetings</h2>
<p>All posts under meetings</p>
<?php query_posts('category_name=Meetings'); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<h2><?php the_title(); ?></h2>
<?php endwhile; endif; ?>
</div>
</div>
<?php include("sideNav.php"); ?>
</div>
<?php get_footer(); ?>
adamstruth@yahoo.com
Member
Posted 2 years ago #
Hi,
Thanks for that - it works, but it is not what I am looking for. I think I explained badly.
Looking for:
post summary and link to the post itself.
I will try to work it out from what you have given me. But if you can do it easily, it would be most appreciated.
Thanks again. Adam.
adamstruth@yahoo.com
Member
Posted 2 years ago #
thanks - from your post I worked it out (below)..... much appreciated
<?php
/*
Template Name: meetings
*/
?>
<?php get_header(); ?>
<div id="content" role="main">
<div id="mainContent">
<div class="post">
<h2>Meetings</h2>
<?php query_posts('category_name=Meetings'); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<h2><?php the_title(); ?></h2>
<?php the_content('Read the rest of this entry »'); ?>
<p><a href="<?php the_permalink(); ?>">Visit post</a></p>
<?php endwhile; endif; ?>
</div>
</div>
<?php include("sideNav.php"); ?>
</div>
<?php get_footer(); ?>
No problem, I wasn't going to write the whole loop for you! :P