WordPress calling all posts in a category and displaying all info instead of only desired info

I am having an issue on this page. I am trying to get the previews (top section) to available homes to appear but not have the actual individual listings (lower section) show on that page. The previews should just be linking to those pages, not displaying them on the main listing pages. I have used the following to set up a shortcode that will display the listing previews.

function available_homes_shortcode() {
   $available_homes = '<div id="available-homes">';
                $slug = 'available-homes';
                $category = get_category_by_slug($slug); 
                query_posts( $query_string . '&cat=' . $category->cat_ID ); 
                while (have_posts()) : the_post(); 

  $available_homes .=   '<div class="single-home">' 
                . '<div class="single-inner">'
                    . '<a href="' . get_the_permalink() . '">'
                        . '<div class="home-image ' . get_field(image_overlay) . '">'
                            . '<img src="' . wp_get_attachment_url( get_post_thumbnail_id($post->ID)) . '"/>'
                        . '</div>'
                        . '<div class="home-title">'
                            . '<p>' . get_field(address)
                            . '<br/>'
                            . get_field(city) . ', ' . get_field(state) . ' ' . get_field(zip_code)
                            . '</p>'
                        . ' </div>'
                    . '</a>'
                    . '<h5 class="h-custom-headline man h5 accent">'
                        . '<span style="float: left;">Details:</span>'
                    . '</h5>'
                    . '<span class="home-style">'
                        . get_field(home_style)
                    . '</span>'
                    . '<br/>'
                    . '<span class="space">'
                        . '• ' . get_field(size_in_square_feet) . ' Sq. Ft. '
                    . '</span>'
                    . '<span class="bedrooms">'
                        . '• ' . get_field(bedrooms) . 'Bed '
                    . '</span>'
                    . '<span class="bathrooms">'
                        . '• ' . get_field(bathrooms) . 'Bath '
                    . '</span>'
                    . '<hr class="x-gap" style="margin: 20px 0 0 0;">'
                    . '<a class="x-btn x-btn-global x-btn-block" href="' . get_the_permalink() . '">'
                        .'More Details'
                    . '</a>'
                    . '<hr class="x-gap" style="margin: 20px 0 0 0;">'
                . '</div>' 
            . '</div>'; 
          endwhile;

   $available_homes .= '</div>';
   return $available_homes;
}

add_filter('init', 'add_available_homes_shortcode');

function add_available_homes_shortcode() {
add_shortcode('available_homes', 'available_homes_shortcode');
}

It would be greatly appreciated if someone could tell me why the info for all of the posts included in that category are showing up instead of only the desired (and stated) info for $available_homes and ideally how to fix it.

Related posts

Leave a Reply