Wordpress category post display help

4 replies
Hey all,

I've been all over the place trying to find help on a project i'm working on right now. Hopefully I can get some help here...Basically, on my wordpress based retail site (le-raq.com/site), I wanted a set of tabs to display posts from a specific category in the main post section. If you take a look, there are three tabs/links, "All, Men, Women". The "All" tab is supposed to load all posts regardless of category, the "Men" tab loads all posts from the category Men, etc etc...

Now, I was using a javascript code that allows you to display different content within a DIV on the same page when a link was clicked on...I tried to apply it to this sitaution for the desired effect, but got an 500 error...i'm not PHP expert, but I assume there is a conflict with the way I assembled the code, and an argument with all the post loops...I'll attach the code I was trying to use... can someone tell me where I went wrong?

Heres the code:

Code:
<?php get_header(); ?>
<div class="home fix" style="padding: 4px;">
    <div class="left">
  <DIV><H1>FILTER SALES BY: <a href="#" onclick="show_visibility('all')">ALL</a> | <a href="#" onclick="show_visibility('men')">MEN</a> | <a href="#" onclick="show_visibility('women')">WOMEN</a></H1></DIV>
 
 
      <div id='lnks'>
        <div class="recent-leads fix">
<!--first-->
          <div id='all' style="display: block;">
            <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
            <div id="post-<?php the_ID(); ?>" class="<?php echo ( is_first_post($post->ID) ) ? 'main-post-bg' : 'secondary-post-bg left'; ?>">
                <p class="post-comments"><?php comments_popup_link('No Comments', '1 Comment', '% Comments'); ?></p>
                <?php if ( is_first_post($post->ID) ) $img_src = get_post_meta($post->ID, 'lead_image', true); 
                    else $img_src = get_post_meta($post->ID, 'secondary_image', true); 
                    if ( $img_src == '' ) $img_src = '/wp-content/themes/theunstandard/images/theunstandard-blank.png';
                ?>
 
                <?php include (TEMPLATEPATH . '/includes/index_dynamic.php'); ?>
 
 
                <div class="title-insert">
                    <h3><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h3>
                </div>
            </div>
            <?php endwhile; ?>
            <?wp_reset_query(); ?>
          </div>
<!--end first part-->
<!--second-->
          <div id='men' style="display: none;">
     <?php query_posts('category_name=men&showposts=10'); ?>
            <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
            <div id="post-<?php the_ID(); ?>" class="<?php echo ( is_first_post($post->ID) ) ? 'main-post-bg' : 'secondary-post-bg left'; ?>">
                <p class="post-comments"><?php comments_popup_link('No Comments', '1 Comment', '% Comments'); ?></p>
                <?php if ( is_first_post($post->ID) ) $img_src = get_post_meta($post->ID, 'lead_image', true); 
                    else $img_src = get_post_meta($post->ID, 'secondary_image', true); 
                    if ( $img_src == '' ) $img_src = '/wp-content/themes/theunstandard/images/theunstandard-blank.png';
                ?>
 
                <?php include (TEMPLATEPATH . '/includes/index_dynamic.php'); ?>
 
 
                <div class="title-insert">
                    <h3><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h3>
                </div>
            </div>
            <?php endwhile; ?>
            <?wp_reset_query(); ?>
          </div>
<!--end second part-->
<!--third-->
          <div id='women' style="display: none;">
     <?php query_posts('category_name=women&showposts=10'); ?> 
            <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
            <div id="post-<?php the_ID(); ?>" class="<?php echo ( is_first_post($post->ID) ) ? 'main-post-bg' : 'secondary-post-bg left'; ?>">
                <p class="post-comments"><?php comments_popup_link('No Comments', '1 Comment', '% Comments'); ?></p>
                <?php if ( is_first_post($post->ID) ) $img_src = get_post_meta($post->ID, 'lead_image', true); 
                    else $img_src = get_post_meta($post->ID, 'secondary_image', true); 
                    if ( $img_src == '' ) $img_src = '/wp-content/themes/theunstandard/images/theunstandard-blank.png';
                ?>
 
                <?php include (TEMPLATEPATH . '/includes/index_dynamic.php'); ?>
 
 
                <div class="title-insert">
                    <h3><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h3>
                </div>
            </div>
            <?php endwhile; ?>
            <?wp_reset_query(); ?>
          </div>
<!--end third part-->
            <div class="entry navigation radius-link fix">
                <br class="clear" />
                <p class="left"><?php previous_posts_link('&laquo; previous'); ?></p><p class="right"><?php next_posts_link('next &raquo;'); ?></p>
            </div>
            <?php else : ?>
            <div class="post single">
                <h2>No matching results</h2>
                <div class="entry">
                    <p>You seem to have found a mis-linked page or search query with no associated or related results.</p>
                </div>
            </div>
            <?php endif; ?>
        </div>
       </div>
     </div>
 
     <div class="right">
  <DIV><H1>COMING UP...</H1></DIV>
        <?php include (TEMPLATEPATH . '/sidebar.php'); ?>
    </div>
</div>
<?php get_footer(); ?>

The javascript used is in the header (not included)...i think the JS is fine, but theres an issue with the way I have the PHP...

Please help!! Thanks!
#category #display #post #wordpress
  • Profile picture of the author SteveJohnson
    500 errors usually aren't caused by PHP, but by a misconfiguration. With WP, the cause is usually a faulty .htaccess file.

    At first glance, I don't see anything wrong with the page coding. I'm assuming that the function is_first_post() is defined in your functions.php file for the theme or in a plugin.
    Signature

    The 2nd Amendment, 1789 - The Original Homeland Security.

    Gun control means never having to say, "I missed you."

    {{ DiscussionBoard.errors[3176311].message }}
    • Profile picture of the author ofields1
      Thanks for the reply!

      Yes, it should be already included...it works without all the modification i put in...but i'll double check...i was just trying to duplicate the same normal result along three seperate divs that showed posts from three different specific categories, and were displayed when one of those three lnks/tabs was clicked.

      What would i need to modify in my .htaccess file to test this?

      Thanks again!
      {{ DiscussionBoard.errors[3176552].message }}
  • Profile picture of the author ofields1
    bump....i still need help with solving this...any ideas?? Thanks
    {{ DiscussionBoard.errors[3187425].message }}
  • Profile picture of the author Ken Durham
    error logs, use them, that's what they are there for

    if that doesn't help then comment out everything that you have added, then open up loops and statements without data. If no error then go down the line of the data handlers until you hit an error. Debugging can be loads of fun at times.
    Signature

    yes, I am....

    {{ DiscussionBoard.errors[3191214].message }}

Trending Topics