• Landon Cahow

    (@redzephyr)


    I’m beyond my capabilities in figuring this problem out.

    What I need to accomplish: On this page I need to display the results of only the items labeled with the term “Doral” under my custom taxonomy of “New Developments” which is a part of the custom post type “Listings”.

    Currently the page is displaying all items regardless of the term or taxonomy for the custom post type “Listing”.

    What I currently have: My custom taxonomy creation code

    add_action('init', 'property_new_dev_taxonomies');
    function property_new_dev_taxonomies() {
    register_taxonomy('new-developments',
            'listing',
            array (
            'labels' => array (
                    'name' => 'New Developments',
                    'singluar_name' => 'New Developments',
                    'search_items' => 'Search New Developments',
                    'popular_items' => 'Popular New Developments',
                    'all_items' => 'All New Developments',
                    'parent_item' => 'Parent New Development',
                    'parent_item_colon' => 'Parent New Development:',
                    'edit_item' => 'Edit New Development',
                    'update_item' => 'Update New Development',
                    'add_new_item' => 'Add New Development',
                    'new_item_name' => 'New Developments',
            ),
                    'hierarchical' => true,
                    'show_ui' => true,
                    'show_tagcloud' => true,
                    'rewrite' => array( 'slug' => 'new-developments'),
                    'query_var' => 'new-developments',
                    'public'=>true)
            );
    }

    My custom taxonomy template (taxonomy-new-developments.php)

    <?php 
    
    /*
        Template Name: Taxonomy New Developments
    */ 
    
    ?>
    
    <?php get_header() ?>
    
    <div id="columnswrapper" class="columns-1">
    <?php get_sidebar(); ?>
        <div id="content" class="norightsidebar">
            <div class="inner">
    
            <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
                    <?php the_content(); ?>
            <?php endwhile; endif; ?>
    
        <?php $term = $wp_query->queried_object; echo '<h2>'.$term->name.'</h2>'; ?>
    
        <?php $term = new WP_Query('post_type=listing', 'taxonomy=new-developments', 'field=slug',  'terms=doral'); ?>
    
        <?php if ($term->have_posts()) : while ($term->have_posts()) : $term->the_post(); ?>
        <?php include 'includes/variables.php' ?>
    
        <div class="searchresult">
    
            <?php
            $arr_sliderimages = get_gallery_images();
            //$firstimage = $arr_sliderimages[0];
            //$arr_sliderimages = parse_url($firstimage);
            $resized = aq_resize($arr_sliderimages[0], 250, 185, true);
            ?>  
    
            <div class="resultimage">
    
                <?php include 'includes/bannerssmall.php'; ?>
    
                <?php if ($mlslisting == "Yes" && $mlsnumber) { ?>
                    <a href="<?php bloginfo('url') ?>/idx/mls-<?php echo $mlsnumber ?>-"><img width="250" height="185" alt="Image for <?php the_title(); ?>" src="<?php echo $resized ?>" /></a>
                <?php } else { ?>
                    <a href="<?php the_permalink(); ?>"><img width="250" height="185" alt="Image for <?php the_title(); ?>" src="<?php echo $resized ?>" /></a>
                <?php } ?>  
    
            </div>
    
            <div class="resultdetails">
                <div class="primary-data">
                    <div class="address">
    
                    <?php if ($mlslisting == "Yes" && $mlsnumber) { ?>
                        <a href="<?php bloginfo('url') ?>/idx/mls-<?php echo $mlsnumber ?>-"><?php the_title() ?>, <?php echo $citystatezip ?></a>
                     <?php } else { ?>
                <a href="<?php the_permalink() ?>"><?php the_title() ?>, <?php echo $citystatezip ?></a>
                <?php } ?>
    
                    </div>
                    <div class="price">
                        <?php include 'includes/price.php'; ?>
                    </div>
                </div>
    
                <div class="secondary-data">
                    <?php if ($beds) { ?>
                        <div><?php echo $beds ?> <?php echo get_option('wp_bedrooms_text'); ?>, <?php echo $baths; ?> <?php echo get_option('wp_bathrooms_text'); ?></div>
                    <?php } ?>
                    <?php if ($homesize) { ?>
                        <div><?php echo get_option('wp_homesize_text') ?>: <?php echo $homesize ?></div>
                    <?php } ?>
                    <?php if ($lotsize) { ?>
                        <div><?php echo get_option('wp_lotsize_text') ?>: <?php echo $lotsize ?></div>
                    <?php } ?>
                    <?php if ($year) { ?>
                        <div><?php echo get_option('wp_yearbuilt_text') ?>: <?php echo $year ?></div>
                    <?php } ?>
                </div>  
    
                <a class="button" href="<?php the_permalink(); ?>"><?php echo get_option('wp_read_more_text') ?></a>
    
            </div><!-- end resultdetails -->
        </div><!-- end searchresult -->
    
            <?php endwhile; else: ?>
            <p><strong>There are no items to display.  Make sure you add 1 or more posts using the "Listings" category.  Also, in Theme Options, make sure the slideshow is using the "Listings" category.</strong></p>
    
            <?php endif;
            wp_reset_query(); ?> 
    
        </div><!-- end inner -->
        </div><!-- end content -->
    </div><!-- end columnswrapper -->
    
    <?php get_footer(); ?>

    I have been trying to get this myself for far too long and desperately need some help to get this working.

    Thanks in advance for your help.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘How to display specific taxonomy term on custom taxonomy template page’ is closed to new replies.