• Stijn
    February 27, 2014 at 3:16 pm #24235

    Hello, on the frontpage of my website I would like to have a list with only the latest featured properties. I can’t figure out how to select this with the shortcodes.
    [recent_items type="properties" category_ids="" action_ids="" city_ids="" area_ids="" number="4" rows="2" link="http://192.168.1.101:3000/YoCuencaV2/?page_id=118"][/recent_items]
    I just want a 2×4 grid of the latest featured properties. Is this possible?

    Anna
    February 28, 2014 at 2:44 am #24289

    Hi Stijn,

    We don’t have just the “featured option” in the shortcode.

    A client did that himself my modifying the recent items shortcode in shortcodes.php file.

    If it helps, this is the code he sent me and he told me it works

    ‘order’ => here is the type (ASC, DESC, RAND),
    ‘meta_query’ => array(
    array(
    ‘key’ => ‘prop_featured’,
    ‘value’ => 1
    )

    Thank you
    Anna

    Stijn
    February 28, 2014 at 2:23 pm #24313

    Thanks for your quick reply! I’ll see what I can do with the code.

    issues
    March 19, 2014 at 12:34 pm #27473

    cannot find “recent_items” in shortcodes.php I see it in shortcodes-install.php and in shortcodes.js but not in shortcodes.php

    Anna
    March 19, 2014 at 3:42 pm #27492

    It’s called $recent_posts (shortcodes.php)

    Gonzalo
    April 11, 2014 at 3:50 pm #30909

    Use this shortcode sample:
    [recent_items type=”properties” only_feat=”1″ category_ids=”” action_ids=”” city_ids=”” area_ids=”” number=”2″ rows=”8″ link=”/properties-list/”][/recent_items]

    Edit shortcodes.php

    function recent_posts_pictures($attributes, $content = null) {
        global $options;
        $return_string='';
        $pictures = '';
        $button='';
        $class='';
        $multiline='';
        $rows=1;
        $onlyfeat=$category=$action=$city=$area='';
        global $post;
        
        
        /* by GEAR invent! */
        if ( isset($attributes['only_feat']) ) {
    	$onlyfeat=$attributes['only_feat'];
        }
        /* gearinvent.com */
    
        if ( isset($attributes['category_ids']) ){
           $category=$attributes['category_ids'];
        }
    
        if ( isset($attributes['action_ids']) ){
           $action=$attributes['action_ids'];
        }
    
        if ( isset($attributes['city_ids']) ){
           $city=$attributes['city_ids'];
        }
    
        if ( isset($attributes['area_ids']) ){
           $area=$attributes['area_ids'];
        }
         
         
        if ( isset($attributes['rows']) ){
            $rows=$attributes['rows'];
        }
        
        if($rows>1){
            $multiline='multiline';
        }
        
        $post_number = $attributes['number'];
        if ($post_number > 5)
            $post_number = 5;
    
        $post_number_total=$post_number*$rows;
        
        if ($attributes['type'] == 'properties') {
            $type = 'estate_property';
            
    	$onlyfeat_array =   '';
            $category_array =   '';
            $action_array   =   '';
            $city_array     =   '';
            $area_array     =   '';
            
        
    	// build onlyfeat cond
            $onlyfeat_cond = 0;
    	if($onlyfeat!=''){
                $onlyfeat_cond = 1;
            }
    
            // build category array
            if($category!=''){
                $category_of_tax=array();
                $category_of_tax=  explode(',', $category);
                $category_array=array(     
                                'taxonomy'  => 'property_category',
                                'field'     => 'term_id',
                                'terms'     => $category_of_tax
                                );
            }
                
            
            // build action array
            if($action!=''){
                $action_of_tax=array();
                $action_of_tax=  explode(',', $action);
                $action_array=array(     
                                'taxonomy'  => 'property_action_category',
                                'field'     => 'term_id',
                                'terms'     => $action_of_tax
                                );
            }
            
            // build city array
            if($city!=''){
                $city_of_tax=array();
                $city_of_tax=  explode(',', $city);
                $city_array=array(     
                                'taxonomy'  => 'property_city',
                                'field'     => 'term_id',
                                'terms'     => $city_of_tax
                                );
            }
            
            // build city array
            if($area!=''){
                $area_of_tax=array();
                $area_of_tax=  explode(',', $area);
                $area_array=array(     
                                'taxonomy'  => 'property_area',
                                'field'     => 'term_id',
                                'terms'     => $area_of_tax
                                );
            }
            
            
            
            
                $args = array(
                    'post_type'         => $type,
                    'post_status'       => 'publish',
                    'paged'             => 0,
                    'posts_per_page'    => $post_number_total,
                    'meta_key'          => 'prop_featured',
                    'orderby'           => 'meta_value  ',
                    'order'             => 'DESC',
                    'tax_query'         => array( 
                                            $category_array,
                                            $action_array,
                                            $city_array,
                                            $area_array
                                        )
                  
                );
            
           
              
        } else {
            $type = 'post';
            $args = array(
                'post_type'      => $type,
                'post_status'    => 'publish',
                'paged'          => 0,
                'posts_per_page' => $post_number_total,
                'cat'            => $category
            );
        }
    
        if ($attributes['link'] != '') {
            if ($attributes['type'] == 'properties') {
                $button .= '<div class="listinglink-wrapper"><div class="btn listing listingbut listinglink"><span class="prop_plus">+</span>'.__(' more listings','wpestate').' </div></div>';
            } else {
                $button .= '<div class="listinglink-wrapper"><div class="btn listing listingblog listinglink"><span class="blog_plus">+</span> '.__(' more articles','wpestate').' </div></div>';
            }
        } else {
            $class = "nobutton";
        }
    
        
        $return_string .= '<div class="article_container bottom-'.$type.' '.$class.'" >';
        
    
    
            if ($attributes['type'] == 'properties') {
                add_filter( 'posts_orderby', 'my_order' ); 
                $recent_posts = new WP_Query($args);
                $count = 1;
                remove_filter( 'posts_orderby', 'my_order' ); 
            }else{
                $recent_posts = new WP_Query($args);
                $count = 1;
            }
       
        
        
        
        while ($recent_posts->have_posts()): $recent_posts->the_post();
       
         $featured  = intval  ( get_post_meta($post->ID, 'prop_featured', true) );
         if ($onlyfeat_cond && !$featured) {
    	//if only featured selected, hide not featured
         } else {
    
            if ( $count % $post_number== 0 && $count!=1) {
                $return_string .= '<article class="col  property_listing '.$multiline.' last">';
            } else {
                $return_string .= '<article class="col  property_listing '.$multiline.' ">';
            }
        
            $link      = get_permalink();
    
            
            // select pictures
            if (has_post_thumbnail()):
                $tumb_img = wp_get_attachment_image_src(get_post_thumbnail_id(), 'property_full');
                switch($post_number){
                    case 1:
                        break;
                        $tumb_img = wp_get_attachment_image_src(get_post_thumbnail_id(), 'property_full');
                    case 2:
                        $tumb_img = wp_get_attachment_image_src(get_post_thumbnail_id(), 'property_full');
                        break;
                    case 3:
                     
                        if ($options['fullwhite']==='fullwhite'){
                            $tumb_img = wp_get_attachment_image_src(get_post_thumbnail_id(), 'property_full');
                        }else{
                            $tumb_img = wp_get_attachment_image_src(get_post_thumbnail_id(), 'property_listings'); 
                        }
                        break;
                    case 4:
                        $tumb_img = wp_get_attachment_image_src(get_post_thumbnail_id(), 'property_listings');
                        break;
                    case 5:
                         $tumb_img = wp_get_attachment_image_src(get_post_thumbnail_id(), 'property_listings');
                        break;
                }
                
               // $tumb_img = wp_get_attachment_image_src(get_post_thumbnail_id(), 'property_listings');
                $return_string .= '<figure>thumb';
            endif;
            
            // ribbons
            if($type == 'estate_property'){
                $prop_stat = get_post_meta($post->ID, 'property_status', true);      
                if( $featured==1){
                    $return_string .='<div class="featured_div">'.__('Featured','wpestate').'</div>';
                }
                if ($prop_stat != 'normal') {
                    $ribbon_class = str_replace(' ', '-', $prop_stat);
                    $return_string .='<div class="ribbon-wrapper-default ribbon-wrapper-' . $ribbon_class . '"><div class="ribbon-inside ' . $ribbon_class . '">' . $prop_stat . '</div></div>';
                }
            }
            
            $return_string .= '          
                    <figcaption class="figcaption-'.$type.'" data-link="' . $link. '">
                        <span class="fig-icon"></span>                   
                    </figcaption>     
                </figure>';
    
           
    
            $return_string .= '
            <div class="property_listing_details"> 
            <h3 class="listing_title">' . get_the_title() . ' </h3>';
    
            if ($attributes['type'] == 'properties') {
                $currency = get_option('wp_estate_currency_symbol', '');
                $where_currency = get_option('wp_estate_where_currency_symbol', '');
    
    
                $price = get_post_meta($post->ID, 'property_price', true);
                if ($price != '') {
                    $price = number_format($price,2,',','.');
    
                    if ($where_currency == 'before') {
                        $price = $currency . ' ' . $price;
                    } else {
                        $price = $price . ' ' . $currency;
                    }
                }
                
                $property_address   = get_post_meta($post->ID, 'property_address', true);
                $property_city      = get_the_term_list($post->ID, 'property_city', '', ', ', '');
                $price_label        = esc_html ( get_post_meta($post->ID, 'property_label', true) );
                
                // property
                $return_string .='<span class="property_price">' . $price .' '.$price_label. '</span>';
                $return_string .='<div class="article_property_type">'.$property_address.', '.$property_city.' </div>';
    
                $return_string .='<div class="article_property_type">'
                                  .get_the_term_list($post->ID, 'property_category', '', ', ', '').' '.__('in','wpestate').' '.get_the_term_list($post->ID, 'property_action_category', '', ', ', '').'
                                  </div>';
             
                
               
                
            } else {
                $return_string .= '<p class="recent_post_p">' . limit_words(get_the_excerpt(), 14) . ' ...</p>';
            }
    
    
    
            $return_string .= '</div></article>';
            $count++;
         }
    
        endwhile;
    
        $return_string .=$button;
    
    
        $return_string .= '</div>';
        wp_reset_query();
        return $return_string;
    }
    
    
    • This reply was modified 3 years, 1 month ago by  Anna.
    Gonzalo
    April 11, 2014 at 3:54 pm #30910

    This blog is editing the content, try this!

    function recent_posts_pictures($attributes, $content = null) {
        global $options;
        $return_string='';
        $pictures = '';
        $button='';
        $class='';
        $multiline='';
        $rows=1;
        $onlyfeat=$category=$action=$city=$area='';
        global $post;
        
        
        /* by GEAR invent! */
        if ( isset($attributes['only_feat']) ) {
    	$onlyfeat=$attributes['only_feat'];
        }
        /* gearinvent.com */
    
        if ( isset($attributes['category_ids']) ){
           $category=$attributes['category_ids'];
        }
    
        if ( isset($attributes['action_ids']) ){
           $action=$attributes['action_ids'];
        }
    
        if ( isset($attributes['city_ids']) ){
           $city=$attributes['city_ids'];
        }
    
        if ( isset($attributes['area_ids']) ){
           $area=$attributes['area_ids'];
        }
         
         
        if ( isset($attributes['rows']) ){
            $rows=$attributes['rows'];
        }
        
        if($rows>1){
            $multiline='multiline';
        }
        
        $post_number = $attributes['number'];
        if ($post_number > 5)
            $post_number = 5;
    
        $post_number_total=$post_number*$rows;
        
        if ($attributes['type'] == 'properties') {
            $type = 'estate_property';
            
    	$onlyfeat_array =   '';
            $category_array =   '';
            $action_array   =   '';
            $city_array     =   '';
            $area_array     =   '';
            
        
    	// build onlyfeat cond
            $onlyfeat_cond = 0;
    	if($onlyfeat!=''){
                $onlyfeat_cond = 1;
            }
    
            // build category array
            if($category!=''){
                $category_of_tax=array();
                $category_of_tax=  explode(',', $category);
                $category_array=array(     
                                'taxonomy'  => 'property_category',
                                'field'     => 'term_id',
                                'terms'     => $category_of_tax
                                );
            }
                
            
            // build action array
            if($action!=''){
                $action_of_tax=array();
                $action_of_tax=  explode(',', $action);
                $action_array=array(     
                                'taxonomy'  => 'property_action_category',
                                'field'     => 'term_id',
                                'terms'     => $action_of_tax
                                );
            }
            
            // build city array
            if($city!=''){
                $city_of_tax=array();
                $city_of_tax=  explode(',', $city);
                $city_array=array(     
                                'taxonomy'  => 'property_city',
                                'field'     => 'term_id',
                                'terms'     => $city_of_tax
                                );
            }
            
            // build city array
            if($area!=''){
                $area_of_tax=array();
                $area_of_tax=  explode(',', $area);
                $area_array=array(     
                                'taxonomy'  => 'property_area',
                                'field'     => 'term_id',
                                'terms'     => $area_of_tax
                                );
            }
            
            
            
            
                $args = array(
                    'post_type'         => $type,
                    'post_status'       => 'publish',
                    'paged'             => 0,
                    'posts_per_page'    => $post_number_total,
                    'meta_key'          => 'prop_featured',
                    'orderby'           => 'meta_value  ',
                    'order'             => 'DESC',
                    'tax_query'         => array( 
                                            $category_array,
                                            $action_array,
                                            $city_array,
                                            $area_array
                                        )
                  
                );
            
           
              
        } else {
            $type = 'post';
            $args = array(
                'post_type'      => $type,
                'post_status'    => 'publish',
                'paged'          => 0,
                'posts_per_page' => $post_number_total,
                'cat'            => $category
            );
        }
    
        if ($attributes['link'] != '') {
            if ($attributes['type'] == 'properties') {
                $button .= '<div class="listinglink-wrapper"><div class="btn listing listingbut listinglink"><span class="prop_plus">+</span>'.__(' more listings','wpestate').' </div></div>';
            } else {
                $button .= '<div class="listinglink-wrapper"><div class="btn listing listingblog listinglink"><span class="blog_plus">+</span> '.__(' more articles','wpestate').' </div></div>';
            }
        } else {
            $class = "nobutton";
        }
    
        
        $return_string .= '<div class="article_container bottom-'.$type.' '.$class.'" >';
        
    
    
            if ($attributes['type'] == 'properties') {
                add_filter( 'posts_orderby', 'my_order' ); 
                $recent_posts = new WP_Query($args);
                $count = 1;
                remove_filter( 'posts_orderby', 'my_order' ); 
            }else{
                $recent_posts = new WP_Query($args);
                $count = 1;
            }
       
        
        
        
        while ($recent_posts->have_posts()): $recent_posts->the_post();
       
         $featured  = intval  ( get_post_meta($post->ID, 'prop_featured', true) );
         if ($onlyfeat_cond && !$featured) {
    	//if only featured selected, hide not featured
         } else {
    
            if ( $count % $post_number== 0 && $count!=1) {
                $return_string .= '<article class="col  property_listing '.$multiline.' last">';
            } else {
                $return_string .= '<article class="col  property_listing '.$multiline.' ">';
            }
        
            $link      = get_permalink();
    
            
            // select pictures
            if (has_post_thumbnail()):
                $tumb_img = wp_get_attachment_image_src(get_post_thumbnail_id(), 'property_full');
                switch($post_number){
                    case 1:
                        break;
                        $tumb_img = wp_get_attachment_image_src(get_post_thumbnail_id(), 'property_full');
                    case 2:
                        $tumb_img = wp_get_attachment_image_src(get_post_thumbnail_id(), 'property_full');
                        break;
                    case 3:
                     
                        if ($options['fullwhite']==='fullwhite'){
                            $tumb_img = wp_get_attachment_image_src(get_post_thumbnail_id(), 'property_full');
                        }else{
                            $tumb_img = wp_get_attachment_image_src(get_post_thumbnail_id(), 'property_listings'); 
                        }
                        break;
                    case 4:
                        $tumb_img = wp_get_attachment_image_src(get_post_thumbnail_id(), 'property_listings');
                        break;
                    case 5:
                         $tumb_img = wp_get_attachment_image_src(get_post_thumbnail_id(), 'property_listings');
                        break;
                }
                
               // $tumb_img = wp_get_attachment_image_src(get_post_thumbnail_id(), 'property_listings');
                $return_string .= '<figure>thumb';
            endif;
            
            // ribbons
            if($type == 'estate_property'){
                $prop_stat = get_post_meta($post->ID, 'property_status', true);      
                if( $featured==1){
                    $return_string .='<div class="featured_div">'.__('Featured','wpestate').'</div>';
                }
                if ($prop_stat != 'normal') {
                    $ribbon_class = str_replace(' ', '-', $prop_stat);
                    $return_string .='<div class="ribbon-wrapper-default ribbon-wrapper-' . $ribbon_class . '"><div class="ribbon-inside ' . $ribbon_class . '">' . $prop_stat . '</div></div>';
                }
            }
            
            $return_string .= '          
                    <figcaption class="figcaption-'.$type.'" data-link="' . $link. '">
                        <span class="fig-icon"></span>                   
                    </figcaption>     
                </figure>';
    
           
    
            $return_string .= '
            <div class="property_listing_details"> 
            <h3 class="listing_title">' . get_the_title() . ' </h3>';
    
            if ($attributes['type'] == 'properties') {
                $currency = get_option('wp_estate_currency_symbol', '');
                $where_currency = get_option('wp_estate_where_currency_symbol', '');
    
    
                $price = get_post_meta($post->ID, 'property_price', true);
                if ($price != '') {
                    $price = number_format($price,2,',','.');
    
                    if ($where_currency == 'before') {
                        $price = $currency . ' ' . $price;
                    } else {
                        $price = $price . ' ' . $currency;
                    }
                }
                
                $property_address   = get_post_meta($post->ID, 'property_address', true);
                $property_city      = get_the_term_list($post->ID, 'property_city', '', ', ', '');
                $price_label        = esc_html ( get_post_meta($post->ID, 'property_label', true) );
                
                // property
                $return_string .='<span class="property_price">' . $price .' '.$price_label. '</span>';
                $return_string .='<div class="article_property_type">'.$property_address.', '.$property_city.' </div>';
    
                $return_string .='<div class="article_property_type">'
                                  .get_the_term_list($post->ID, 'property_category', '', ', ', '').' '.__('in','wpestate').' '.get_the_term_list($post->ID, 'property_action_category', '', ', ', '').'
                                  </div>';
             
                
               
                
            } else {
                $return_string .= '<p class="recent_post_p">' . limit_words(get_the_excerpt(), 14) . ' ...</p>';
            }
    
    
    
            $return_string .= '</div></article>';
            $count++;
         }
    
        endwhile;
    
        $return_string .=$button;
    
    
        $return_string .= '</div>';
        wp_reset_query();
        return $return_string;
    }
    
    Gonzalo
    April 11, 2014 at 3:58 pm #30911

    LAST CONTENT WAS MODIFIED ALSO

    Just add the $onlyfeat code. And keep the rest from present file.

    Anna
    April 11, 2014 at 4:34 pm #30916

    Thank you, Gonzalo! I can’t make the code not be formatted either 🙂

    It’s clear though.

    Million thanks!
    Anna

    Tony
    May 28, 2014 at 8:08 am #39338

    Hi Gonzalo,
    I’m interested in this feature too, but with the trouble in the blog function I am uncertain which aspects of the code here are usable. Would you mind sending a file or the code snippet that makes this work to hdrprophoto@yahoo.com
    ?
    Much appreciated
    Tony

    Tony
    June 10, 2014 at 10:55 am #41453

    Can we get this implemented as a standard feature of WPESTATE? I am not sure exactly what is being done here as I am not a PHP programmer.
    If the code is already available, and thus made into a sticky, surely it can be implemented in some way as a new shortcode or template. Is this planned for the next update?

You must be logged in to reply to this topic.

Contact Us

We're not around right now. But you can send us an email and we'll get back to you, asap.