I've run into a problem. I've created a theme that has two different single.php layouts. So i have single1.php and single2.php. The default single.php file looks like this: <?php $post = $wp_query->post; if ( in_category('69') || in_category('70') ) { include(TEMPLATEPATH . '/single-artist.php'); } else { include(TEMPLATEPATH . '/single-review.php'); } ?> Code (markup): This seems to work in terms of displaying differnt post layouts depending on which category the post comes from (which is what I want). The problem I have is, that no matter what post link i click on, the post content is the same, even though the urls are different. Does that make sense? So http://www.blog.com/post1, http://www.blog.com/post2, http://www.blog.com/post3 all display the same content even though their urls are different and the post content should also be different. Anyone have any ideas as to how I could fix this?
Thanks. I'm actually just realising I don't think I have a loop happening at all Here's the index.php, anyone able to tell me whats missing and where?: <?php get_header() ?> <div id="content"> <div id="news"> <h2 class="feature">Latest News</h2> <?php $my_query = new WP_Query('category_name=Parent Category 1&showposts=1'); while ($my_query->have_posts()) : $my_query->the_post(); $do_not_duplicate = $post->ID; ?> <h2 class="post-title"><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2> <p class="byline"> <span class="time"><?php the_time('F jS, Y') ?></span> </p> <div class="entry"> <?php the_excerpt(); ?> <p class="post-meta-data"><?php comments_popup_link('No Comments', '1 Comment', '% Comments'); ?> | <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">Read full story »</a></p> </div><!-- entry --> <?php endwhile; ?> </div> <div id="rigs"> <h2 class="feature">Feature</h2> <?php $my_query = new WP_Query('category_name=Parent Category 1&showposts=1'); while ($my_query->have_posts()) : $my_query->the_post(); $do_not_duplicate = $post->ID; ?> <h2 class="post-title"><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2> <p class="byline"> <span class="time"><?php the_time('F jS, Y') ?></span> </p> <div class="entry"> <?php the_excerpt(); ?> <p class="post-meta-data"><?php comments_popup_link('No Comments', '1 Comment', '% Comments'); ?> | <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">Read full story »</a></p> </div><!-- entry --> <?php endwhile; ?> </div> <div id="adsense300x250"> ad </div> <div id="title-box"><h2 class="feature">5 posts by category</h2></div> <!--- I WANT EVERYTHING WITHIN THE "box" div id TO BE REPEATED FOR EVERY CHILD CATEGORY WITHIN A SPECIFIC PARENT CATEGORY --> <div id="box"> <div id="box-content"> <div id="box-header">Category 1</div> <p><?php query_posts('category_name=Parent Category 1&showposts=5'); ?> <?php while (have_posts()) : the_post(); ?> <li><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></li> <?php endwhile;?></p> </div> </div> </div><!-- #content --> <?php get_sidebar() ?> <?php get_footer() ?> Code (markup):
just so i fully understand, your trying to get one single page to display as X if its is from category Y and you want the single page to display Y if it is from category X? e.g. category = reviews == single posts should now show the review template category = artists == single posts should now show the artist profile template is that what your after?
you should use category templates and then in each category template include a sidebar replace <?php get_sidebar(); ?> with <?php include ('your-sidebar.php'); ?> PHP: http://mycyc.com/blogging-tips-creating-custom-category-templates-in-wordpress/ http://codex.wordpress.org/Category_Templates
That doesn't need to be in the loop, just put it at the top of the page. Not sure why $post = $wp_query->post; is there(maybe for something else?). Try using the regular loop instead of myQuery and use query_posts() instead.