Wordpress Category display in Pages problem

I'm having two problems related to the same ambition.

Using the default Wordpress theme, I created a page for each section of my website. Then I created a category to match each of those pages. I want to be able to create a post, assign that post a category, and then have it appear in it's corresponding page with the ability to comment on that post. I figured out that I needed to add query_posts(); to the page template. This sort of works but here's the problems I'm having with it:

1) I can't figure out the proper if statements to organize it all properly, it is showing all posts on all pages I do it for.

2) The posts it displays has no comment or rss fields. So they are just static. I want people to be able to comment on my posts.

P.S. If I don't use the query_posts(); function then comments will work!

This is what I have for my page.php template.
<?php
/**
 * @package WordPress
 * @subpackage Default_Theme
 */
 
get_header(); ?>
 
	<div id="content" class="narrowcolumn">
 
		<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
 
		<div class="post" id="post-<?php the_ID(); ?>">
		<h1><?php the_title(); ?></h1>
			<div class="entry">
				<?php the_content('<p class="serif">Read the rest of this page &raquo;</p>'); ?>
 
				<?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number'));
?>
<?php 
 
if(is_page('Healthy Food')) {
query_posts('cat=you-and-your-baby&showposts=-1');
 
if(is_page('You and Your Baby')) {
query_posts('cat=you-and-your-baby&showposts=-1');
 
};
 
?>
 
			</div>
		</div>
 
		<?php endwhile; endif; ?>
 
</div>
 
<?php
 
if(is_page('1')) {
 
     echo 'Hi There!';
 
} elseif (is_page('Healthy Food')) {
 
     echo '<div id=sidebar>
<h1>Featured Product</h1><p class="centered">DERMAdoctor<br /><a href=http://click.linksynergy.com/fs-bin/click?id=mir9zur4eS8&offerid=30329.10000043&type=4&subid=0><img width=120 height=60 alt=Banner 10000043 border=0 src=http://www.dermadoctoraffiliates.com/graphics/images/alwaysin120x60.gif></a><img border=0 width=1 height=1 src=http://ad.linksynergy.com/fs-bin/show?id=offJEA3lmBg&bids=mir9zur4eS8&type=4&subid=0></p>
 
<p>For sheer information, it\'s tough to beat DERMAdoctor\'s feature articles and newsletters where Dr. Kunin shares the most current developments in skin care technology and research. This is what separates DERMAdoctor.com from other retailers on the web.</p>
<p>Accurate information gives you the power to make the right skin care choices from our wide array of products. And for the shopper in a hurry, some guests prefer to browse the extensive listings of products and descriptions.</a></p></div>';
 
} elseif (is_page('How You Clean')) {
 
     echo '<div id="sidebar">
<h1>Featured Product</h1><p class="centered">Aquasana.com<br /><a href=http://www.aquasanaaffiliates.com/b.asp?id=4270>
<img src=http://www.aquasanaaffiliates.com/showban.asp?id=4270&img=banner7.jpg border=0></a></p><p>This water filter is perfect for your home. We have done our research and have found this to be the most economical solution available. We give it our full endorsement and know youll just love the system.</p></div>';
     
} elseif (is_page('Around the House')) {
 
     echo '<div id=sidebar><p><a href="http://www.greensuperfood.com/?Click=4578">Click here to visit greensuperfood.com</a></p></div>';
     
} elseif (is_page('Out and About')) {
 
     echo '<div id=sidebar>Out and Aboot</div>';
     
} elseif (is_page('You and Your Baby')) {
     
     echo '<div id=sidebar>You & Bebeh</div>';
 
} elseif (is_page('Healthy Pets')) {
     
     echo '<div id=sidebar>Smetz</div>';
 
}
 
else {
 
     echo '<div id="sidebar"><h1>Featured Product</h1><p class="centered">Bulk Herbs - Great Value!<br /><br />
If you&#39;re looking to buy in quantity and want a great low price, then check out these guys:<br /><br /> 
<a href="http://www.morethanalive.com/?a_aid=e970b042&amp;a_bid=75abec25"><img src="http://join.morethanalive.com/scripts/sb.php?a_aid=e970b042&amp;a_bid=75abec25" alt="www.morethanalive.com" border="0" title="www.morethanalive.com"></a></p></div>';
 
}
 
?>
 
<?php get_footer(); ?>

Open in new window

jameshuckabonetechAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

gwkgCommented:
Have you looked over this page?

http://codex.wordpress.org/Template_Tags/query_posts

For one, you need to query the posts BEFORE you loop through them.
0
gwkgCommented:
by "query the posts" I mean the function query_posts( )
0
jameshuckabonetechAuthor Commented:
Well, the thing is, I want the specific page's text to come up first, and then the post that are marked with that page's category to appear under that. For Instance, if the page is called "You and your baby". I want to have an introductory paragraph for that section. And then underneath that introductory paragraph I would like all of the posts that I categorized as "you-and-your-baby" (created a category similar to the page name) to appear underneath the introductory paragraph. It seems thats if I put the query_posts function before the loop, then it overrides the display of the page text I created. Am I making any sense?
0
Starting with Angular 5

Learn the essential features and functions of the popular JavaScript framework for building mobile, desktop and web applications.

gwkgCommented:
I understand a little better now.  I think this page will help

http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates

Especially look at  'A Page of Posts' and how they use WP_Query($args); to display the posts from a specific category on a page.

This explains WP_Query to start a new "loop"

http://weblogtoolscollection.com/archives/2008/04/13/define-your-own-wordpress-loop-using-wp_query/
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
gwkgCommented:
You also are missing a closing } on line 24 is that just a typo?
0
jameshuckabonetechAuthor Commented:
Thanks for pointing me in the right direction!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Blogs

From novice to tech pro — start learning today.