New tab for table - category match

Hello. I need help!

I’m not a coder but I’m trying to update a website that’s on Wordpress. I am trying to add a tab to a php template. I have been successful in adding the tab but the content on the tab does not return the correct content. There are four categories: retail, office, industrial and available. The tabs are retail, office, industrial and all. There is a separate page that has the “available” listing, but I am trying to combine the two pages so there is one box with five tabs: retail, office, industrial, all and available.

I have been successful in adding the available tab, but it only returns what’s on the “all” tab. I cannot figure out how to pull all those categorized as available into a tab that lists all of those available. What script/code is needed? I’ve included the full php below including my addition of the available tab.

Your help is greatly appreciated!!
Thanks - Aintree

[php]<?php
/*
Template Name: Property Listing
*/

get_header(); ?>

<?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(); ?></div>
</div> <!-- .post -->
<?php endwhile; endif; ?>

<div id="tabbed_box_1" class="tabbed_box">

<div class="tabbed_area">

    <ul class="tabs">
        <li><a href="#" title="retail" class="tab active">Retail</a></li>
        <li><a href="#" title="industrial" class="tab">Industrial</a></li>
        <li><a href="#" title="office" class="tab">Office</a></li>
        <li><a href="#" title="all" class="tab">All</a></li>
        <li><a href="#" title="all" class="tab">Available</a></li>
    <?php $pq = array('orderby'=>'title','order'=>'ASC','nopaging'=>true,'post_type'=>'property'); ?>
    <?php if (is_page(46)): $pq['category__and'] = array(7); endif; ?>
    
    <div id="retail" class="tab_content">
    	<?php 
		$rq = $pq;
		if (isset($pq['category__and'])) $rq['category__and'][] = 4;
		else $rq['cat'] = 4;
		$retail_query = new WP_Query($rq); ?>
		<?php print property_loop($retail_query); ?>
    </div>
    <div id="industrial" class="tab_content">
    	<?php 
		$iq = $pq;
		if (isset($pq['category__and'])) $iq['category__and'][] = 6;
		else $iq['cat'] = 6;
		$industrial_query = new WP_Query($iq); ?>
		<?php print property_loop($industrial_query); ?>
    </div>
    <div id="office" class="tab_content">
    	<?php 
		$oq = $pq;
		if (isset($pq['category__and'])) $oq['category__and'][] = 5;
		else $oq['cat'] = 5;
		$office_query = new WP_Query($oq); ?>
        <?php print property_loop($office_query); ?>
    </div>
    <div id="all" class="tab_content">
    	<?php $all_query = new WP_Query($pq); ?>
        <?php print property_loop($all_query); ?>
    <div id="available" class="tab_content">
         </div>

    </div>

</div>
<?php function property_loop($query) { $c = 0; $return = ""; if ( $query->have_posts() ) : while ($query->have_posts()) : $query->the_post(); $meta = get_post_meta( get_the_ID() ); $return .= '
'. get_the_title().'
'.$meta['property_location'][0].' 
'; $return .= '
'; if (isset($meta['property_costar_url'])): $return .= 'LoopNet'; endif; $return .= '
'; if (isset($meta['property_pdf'])): $pdf = unserialize($meta['property_pdf'][0]); $return .= 'PDF View'; endif; if (isset($meta['property_pdf_2'])): $pdf = unserialize($meta['property_pdf_2'][0]); $return .= 'PDF View'; endif; $return .= '
'; endwhile; else: $return .= '

No properties at this time.

'; endif; return $return; }?> <?php get_footer(); ?>

[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service