problem with wordpress theme coding

Discussion in 'HTML & Website Design' started by swollenpickles, Apr 13, 2008.

  1. #1
    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?
     
    swollenpickles, Apr 13, 2008 IP
  2. just-4-teens

    just-4-teens Peon

    Messages:
    3,967
    Likes Received:
    168
    Best Answers:
    0
    Trophy Points:
    0
    #2
    im guessing that the above code has been posted within the wordpress loop?
     
    just-4-teens, Apr 13, 2008 IP
  3. swollenpickles

    swollenpickles Active Member

    Messages:
    1,271
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    80
    #3
    Thanks. I'm actually just realising I don't think I have a loop happening at all :eek:

    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 &raquo;</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 &raquo;</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):
     
    swollenpickles, Apr 14, 2008 IP
  4. just-4-teens

    just-4-teens Peon

    Messages:
    3,967
    Likes Received:
    168
    Best Answers:
    0
    Trophy Points:
    0
    #4
    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?
     
    just-4-teens, Apr 14, 2008 IP
  5. swollenpickles

    swollenpickles Active Member

    Messages:
    1,271
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    80
    #5
    Thanks for the reply. Yes, that is what I'm after.
     
    swollenpickles, Apr 14, 2008 IP
  6. swollenpickles

    swollenpickles Active Member

    Messages:
    1,271
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    80
    #6
    I tried pluggin it within the 'content' div, but I still couldn't get it working :(
     
    swollenpickles, Apr 16, 2008 IP
  7. just-4-teens

    just-4-teens Peon

    Messages:
    3,967
    Likes Received:
    168
    Best Answers:
    0
    Trophy Points:
    0
    #7
    just-4-teens, Apr 16, 2008 IP
  8. Svenson

    Svenson Peon

    Messages:
    34
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    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.
     
    Svenson, Apr 16, 2008 IP