Jump to content

Displaying Posts in Categories in Wordpress


dbhynds

Recommended Posts

I'm creating a website using WordPress, www.dougberkytheatre.com.I'm new to php (really new, as in learning it for this project) and I'm having some trouble getting it to do what I want.I have several posts labelled under Category 3. I want to display the titles of each page in the navigation. I can get it to display correctly, but any time you click the link to load a page, always loads the same post.Here is the code I have for the navigation:

<table border=0 cellpadding=0 cellspacing=0><tr><?php query_posts('cat=3'); ?><?php while (have_posts()) : the_post(); ?><td class="nav" nowrap><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></td><td><img src="/images/navdivider.gif"></td><?php endwhile; ?><td class="nav" width="100%"></td></tr></table>

Here is my code for the main body of my page:

<h1><?php the_title(); ?></h1><?php the_content(); ?>

So here's the problem, the site automatically loads the page entitled "Test Post." However, when you click "Test post 2" it will load "Test Post" instead. Basically, any link you click will always display "Test Post."I think the "<?php query_posts('cat=3'); ?>" code is somehow causing it, because when I delete that, everything works fine. The problem is that I don't want posts in Category 4 to be displayed in the navigation, and deleting this code causes Category 4 posts to be displayed. Oh, the other wierd thing that tells me it's somehow connected to that line of code is that when I move the Navigation code below the Main Body, everything works fine. So it's like the query_post function is somehow getting hung up on the last post in the category (which is "Test Post"), but only does so if the function occurs before the main body code.Can someone help me out here? I'm completely new to php.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...