Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Adding Pro Ajax Search to WP Pro Real Estate 7
This topic contains 10 replies, has 2 voices, and was last updated by Ernest Marcinko 4 years, 9 months ago.
- AuthorPosts
- August 26, 2018 at 5:51 pm #19057
Hi, sorry, I thought I had this figured out. I am using Realestate Pro 7 and currently have a single listing page that groups according to status and then price.
I want to implement Pro Ajax Search without having to rewrite the entire template page. What is the best way to add the Ajax search?
I have been attempting to modify the result page horizontal.php, but I think it would be better to integration with the WP template I use.
Here is an example of my first attempted, but the formatting isn’t working.
Here is the page that I want to integrate Ajax Pro Search into
Real Estate Pro 7 Listing Widget
<?php /** * Listings * * @package WP Pro Real Estate 7 * @subpackage Widget */ class ct_Listings extends WP_Widget { function __construct() { $widget_ops = array('description' => 'Display your latest listings.' ); parent::__construct(false, __('CT Listings', 'contempo'),$widget_ops); } function widget($args, $instance) { extract( $args ); $title = $instance['title']; $number = $instance['number']; $taxonomy = $instance['taxonomy']; $tag = $instance['tag']; $viewalltext = $instance['viewalltext']; $viewalllink = $instance['viewalllink']; ?> <?php echo $before_widget; ?> <?php if ($title) { echo $before_title . $title . $after_title; } echo '<ul>'; global $ct_options; $ct_search_results_listing_style = isset( $ct_options['ct_search_results_listing_style'] ) ? $ct_options['ct_search_results_listing_style'] : ''; global $post; global $wp_query; wp_reset_postdata(); $args = array( 'post_type' => 'listings', 'order' => 'DSC', $taxonomy => $tag, 'posts_per_page' => $number, 'tax_query' => array( array( 'taxonomy' => 'ct_status', 'field' => 'slug', 'terms' => 'ghost', // exclude media posts in the news-cat custom taxonomy 'operator' => 'NOT IN' ), ) ); $wp_query = new wp_query( $args ); if ( $wp_query->have_posts() ) : while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?> <li class="listing <?php echo $ct_search_results_listing_style; ?>"> <?php if(has_post_thumbnail()) { ?> <figure> <?php if(has_term( 'featured', 'ct_status' ) ) { echo '<h6 class="snipe featured">'; echo '<span>'; echo __('Featured', ''); echo '</span>'; echo '</h6>'; } ?> <?php $status_tags = strip_tags( get_the_term_list( $wp_query->post->ID, 'ct_status', '', ' ', '' ) ); if($status_tags != ''){ echo '<h6 class="snipe status '; $status_terms = get_the_terms( $wp_query->post->ID, 'ct_status', array() ); if ( ! empty( $status_terms ) && ! is_wp_error( $status_terms ) ){ foreach ( $status_terms as $term ) { echo esc_html($term->slug) . ' '; } } echo '">'; echo '<span>'; echo esc_html($status_tags); echo '</span>'; echo '</h6>'; } ?> <?php ct_property_type_icon(); ?> <?php ct_listing_actions(); ?> <?php ct_first_image_linked_widget(); ?> </figure> <?php } ?> <div class="grid-listing-info"> <header> <h5 class="marB0"><a>><?php ct_listing_title(); ?></a></h5> <p class="location marB0"><?php city(); ?>, <?php state(); ?> <?php zipcode(); ?><?php country(); ?></p> </header> <p class="price marB0"><?php ct_listing_price(); ?></p> <ul class="propinfo marB0"> <?php ct_propinfo(); ?> </ul> <?php ct_listing_creation_date(); ?> <?php ct_brokered_by(); ?> <div class="clear"></div> </li> <?php endwhile; endif; wp_reset_postdata(); ?> <?php echo '</ul>'; ?> <?php if($viewalltext) { ?> <p id="viewall"><a>"><?php echo esc_html($viewalltext); ?> <em>→</em></a></p> <?php } ?> <?php echo $after_widget; ?> <?php } function update($new_instance, $old_instance) { return $new_instance; } function form($instance) { $title = isset( $instance['title'] ) ? esc_attr( $instance['title'] ) : ''; $number = isset( $instance['number'] ) ? esc_attr( $instance['number'] ) : ''; $taxonomy = isset( $instance['taxonomy'] ) ? esc_attr( $instance['taxonomy'] ) : ''; $tag = isset( $instance['tag'] ) ? esc_attr( $instance['tag'] ) : ''; $viewalltext = isset( $instance['viewalltext'] ) ? esc_attr( $instance['viewalltext'] ) : ''; $viewalllink = isset( $instance['viewalllink'] ) ? esc_attr( $instance['viewalllink'] ) : ''; ?> <p> <label for="<?php echo $this->get_field_id('title'); ?>"><?php esc_html_e('Title:','contempo'); ?></label> <input type="text" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo esc_attr($title); ?>" class="widefat" id="<?php echo $this->get_field_id('title'); ?>" /> </p> <p> <label for="<?php echo $this->get_field_id('number'); ?>"><?php esc_html_e('Number:','contempo'); ?></label> <select name="<?php echo $this->get_field_name('number'); ?>" class="widefat" id="<?php echo $this->get_field_id('number'); ?>"> <?php for ( $i = 1; $i <= 10; $i += 1) { ?> <option value="<?php echo $i; ?>" <?php if($number == $i){ echo "selected='selected'";} ?>><?php echo $i; ?></option> <?php } ?> </select> </p> <p> <label for="<?php echo $this->get_field_id('taxonomy'); ?>"><?php esc_html_e('Taxonomy:','contempo'); ?></label> <select name="<?php echo $this->get_field_name('taxonomy'); ?>" class="widefat" id="<?php echo $this->get_field_id('taxonomy'); ?>"> <?php foreach (get_object_taxonomies( 'listings', 'objects' ) as $tax => $value) { ?> <option value="<?php echo $tax; ?>" <?php if($taxonomy == $tax){ echo "selected='selected'";} ?>><?php echo $tax; ?></option> <?php } ?> </select> </p> <p> <label for="<?php echo $this->get_field_id('tag'); ?>"><?php esc_html_e('Tag:','contempo'); ?></label> <input type="text" name="<?php echo $this->get_field_name('tag'); ?>" value="<?php echo $tag; ?>" class="widefat" id="<?php echo $this->get_field_id('tag'); ?>" /> </p> <p> <label for="<?php echo $this->get_field_id('viewalltext'); ?>"><?php esc_html_e('View All Link Text','contempo'); ?></label> <input type="text" name="<?php echo $this->get_field_name('viewalltext'); ?>" value="<?php echo $viewalltext; ?>" class="widefat" id="<?php echo $this->get_field_id('viewalltext'); ?>" /> </p> <p> <label for="<?php echo $this->get_field_id('viewalllink'); ?>"><?php esc_html_e('View All Link URL','contempo'); ?></label> <input type="text" name="<?php echo $this->get_field_name('viewalllink'); ?>" value="<?php echo $viewalllink; ?>" class="widefat" id="<?php echo $this->get_field_id('viewalllink'); ?>" /> </p> <?php } } register_widget('ct_Listings'); ?>
August 27, 2018 at 11:38 am #19062Hi!
Thank you for the details, it helps us a lot!
Unfortunately the link to the page, where the plugin should be visible is broken. I am not entirely sure, what exactly are you trying to achieve yet. I believe, that the best possible implementation always depends on the situation. Usually, using the plugin shortcode on a page is the best way.
You can also enable search results page override, so when redirecting to the results page, the plugin will try to push it’s own result to the results page template.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
August 27, 2018 at 6:51 pm #19067Hi- Sorry, the page was set to private.
Here is the layout of the current Portflio Listing
Current ResultsI want to add ASP to this page layout. I modified the ASP horizontal results page, but here
But I have been unable to match the layout of the original Portfolio Listing.
modified horizontal.php
<?php /* Prevent direct access */ defined('ABSPATH') or die("You can't access this file directly."); /** * This is the default template for one horizontal result * * !!!IMPORTANT!!! * Do not make changes directly to this file! To have permanent changes copy this * file to your theme directory under the "asp" folder like so: * wp-content/themes/your-theme-name/asp/horizontal.php * * It's also a good idea to use the actions to insert content instead of modifications. * * You can use any WordPress function here. * Variables to mention: * Object() $r - holding the result details * Array[] $s_options - holding the search options * * DO NOT OUTPUT ANYTHING BEFORE OR AFTER THE <div class='item'>..</div> element * * You can leave empty lines for better visibility, they are cleared before output. * * MORE INFO: https://wp-dreams.com/knowledge-base/result-templating/ * * @since: 4.0 */ ?> <div class='vc_row wpb_row vc_row-fluid item listing col standard<?php echo apply_filters('asp_result_css_class', $asp_res_css_class); ?>'> <?php do_action('asp_res_horizontal_begin_item'); ?> <?php $propertyid = $r->id; $ct_property_type = strip_tags( get_the_term_list( $propertyid, 'property_type', '', ', ', '' ) ); $price = get_post_meta( $r->id, '_ct_price', true ); $sqft = get_post_meta( $r->id, '_ct_sqft', true ); $lotsize = get_post_meta( $r->id, '_ct_lotsize', true ); $beds = strip_tags( get_the_term_list( $r->id, 'beds', '', ', ', '' ) ); $baths = strip_tags( get_the_term_list( $r->id, 'baths', '', ', ', '' ) ); $thumbnail = get_the_post_thumbnail( $r->id); $description = strip_tags(get_post_field('post_content', $r->id)); $shortdescription = substr($description,0,200); $link = $r->link; $status_tags = strip_tags( get_the_term_list( $propertyid, 'ct_status', '', ' ', '' ) ); $city = strip_tags( get_the_term_list( $r->id, 'city', '', ', ', '' ) ); $state = strip_tags( get_the_term_list( $r->id, 'state', '', ', ', '' ) ); $zip = strip_tags( get_the_term_list( $r->id, 'zipcode', '', ', ', '' ) ); $alttitle = get_post_meta( $r->id, '_ct_listing_alt_title', true ); ?> <?php if (!empty($r->image)): ?> <a>link; ?>'<?php echo ($s_options['results_click_blank'])?" ' target='_blank'":""; ?>> <figure> <?php if($status_tags != ''){ echo '<h6 class="snipe status '; $status_terms = get_the_terms( $propertyid, 'ct_status', array() ); foreach ( $status_terms as $term ) { echo esc_html($term->slug) . ' '; } echo '"style="display:block">'; echo '<span>'; echo esc_html($status_tags); echo '</span>'; echo '</h6>'; } echo '<div class="propertyThumb">'.$thumbnail.'</div>'; echo '<span class="prop-type-icon"><i class="fa fa-home"></i></span>'; ?> </figure> </a> <?php endif; ?> <?php do_action('asp_res_horizontal_after_image'); ?> <div class='asp_content'> <div class="grid-listing-info"> <header> <h5><a>link; ?>'<?php echo ($s_options['results_click_blank'])?" target='_blank'":""; ?>><?php echo $alttitle; ?> <?php if ($s_options['resultareaclickable'] == 1): ?> <span class='overlap'></span> <?php endif; ?> </a></h5> <p class="location marB0"><?php echo $city;?>, <?php echo $state;?> <?php echo $zip;?></p> </header> </div> <div class='etc'> <?php if ($s_options['showauthor'] == 1): ?> <span class='asp_author'><?php echo $r->author; ?></span> <?php endif; ?> <?php if ($s_options['showdate'] == 1): ?> <span class='asp_date'><?php echo $r->date; ?></span> <?php endif; ?> </div> <?php if ($s_options['showdescription'] == 1): ?> <?php if (!empty($r->image) && $s_options['hhidedesc'] == 0): ?> <?php echo $r->content; ?> <?php endif; ?> <?php endif; ?> </div> <?php do_action('asp_res_horizontal_after_content'); ?> <div class='clear'></div> <?php do_action('asp_res_horizontal_end_item'); ?> </div>
August 28, 2018 at 3:56 am #19071Does the horizontal.php add the template CSS?
August 28, 2018 at 3:56 am #19072Also, how do I pull in additional meta and terms?
August 28, 2018 at 12:17 pm #19083Hi!
Please note, that customizations are not part of the support process. I will try to help you as much as I can, but I cannot guarantee anything here.
I think this is a bit overly complicated in places. Can you please check the FTP access? I am not able to open the public_html directory with the credentials. Thank you!
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
August 28, 2018 at 11:03 pm #19086I understand this is beyond your support process, I apologize. I really like the functionality of the plugin and it is a unique function that I would like to implement in this website and several others. I appreciate you pointing me in the right direction, but also know you can’t focus a significant amount of your time on a single licensee.
I have corrected the FTP access.
August 30, 2018 at 1:20 am #19090Hello-
I worked out my layout issue, I had to create entirely new div and CSS, but it is working, so thank you for your office of assistance, but I have solved that issue.
If you have an quick answer for this.
I need to order the results _ct_status and _ct_price. _ct_status is a term and _ct_price is a postmeta.
I put these in the General Options->ordering but it seems to have no consequence on the how the results are displayed.
August 30, 2018 at 7:17 am #19091Hi!
Great job!
Ordering by a taxonomy term is not possibe there, but the custom field should work. I cannot access the site right now, I am getting a wordfence error, so I cannot check: https://image.ibb.co/n7EJ8U/download.png
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
August 31, 2018 at 6:55 pm #19116Hi-
The URL login is:
https://www.carswellandpartners.com/userlogin
I have unblocked your IP, I assumed it was the ones from Turkey.
I need to be able to change the order of the results so they are sorted by the _ct_status in a certain order based on taxonomy , then the _ct_price DSC.
Is there a way to take $r and change the order of the array before it is sent to the horizontal.php template or something like that.
Thanks!
September 3, 2018 at 10:10 am #19132Sure!
The asp_results filter is the one you are looking for. That you can use to manipulate results before they are passed to the result template files.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
- AuthorPosts
You must be logged in to reply to this topic.