• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Modify Search Function

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › Design Tips and Tricks › Modify Search Function

This topic is: resolved

Tagged: agent press search

  • This topic has 3 replies, 2 voices, and was last updated 9 years, 10 months ago by brent s.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • September 4, 2015 at 1:21 pm #164603
    brent s
    Member

    I have asked a similar question and I need a little more guidance. I have modified the search code as shown below. Essentially, I took this line of code and the bolded language used to be "hidden" now I have made it "textbox." and a textbox appears. When I run a search based on registered taxonomies, it works with some taxonomies, but not another. Of course, I need the one not being searched. What else do I modify to search a specific registered taxonomy?

    echo '<form role="search" method="get" id="searchform" action="' . home_url( '/' ) . '" ><input type="<strong>textbox</strong>" value="" name="s" /><input type="hidden" value="listing" name="post_type" />';

    <?php
    /**
     * This widget presents a search widget which uses listings' taxonomy for search fields.
     *
     * @package AgentPress
     * @since 2.0
     * @author Ron Rennick
     */
    class AgentPress_Listings_Search_Widget extends WP_Widget {
    
    	function __construct() {
    		$widget_ops = array( 'classname' => 'property-search', 'description' => __( 'Display property search dropdown', 'agentpress-listings' ) );
    		$control_ops = array( 'width' => 200, 'height' => 250, 'id_base' => 'property-search' );
    		parent::__construct( 'property-search', __( 'AgentPress - Listing Search', 'agentpress-listings' ), $widget_ops, $control_ops );
    	}
    
    	function widget( $args, $instance ) {
    		
    		$instance = wp_parse_args( (array) $instance, array(
    			'title'       => '',
    			'button_text' => __( 'Search Properties', 'agentpress-listings' )
    		) );
    
    		global $_agentpress_taxonomies;
    
    		$listings_taxonomies = $_agentpress_taxonomies->get_taxonomies();
    
    		extract( $args );
    
    		echo $before_widget;
    
    		if ( $instance['title'] ) echo $before_title . apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ) . $after_title;
    
    		echo '<form role="search" method="get" id="searchform" action="' . home_url( '/' ) . '" ><input type="<strong>textbox</strong>" value="" name="s" /><input type="hidden" value="listing" name="post_type" />';
    
    		foreach ( $listings_taxonomies as $tax => $data ) {
    			if ( ! isset( $instance[$tax] ) || ! $instance[$tax] )
    				continue;
    
    			$terms = get_terms( $tax, array( 'orderby' => 'count', 'order' => 'DESC', 'number' => 100, 'hierarchical' => false ) );
    			if ( empty( $terms ) )
    				continue;
    
    			$current = ! empty( $wp_query->query_vars[$tax] ) ? $wp_query->query_vars[$tax] : '';
    			echo "<select name='$tax' id='$tax' class='agentpress-taxonomy'>\n\t";
    			echo '<option value="" ' . selected( $current == '', true, false ) . ">{$data['labels']['name']}</option>\n";
    			foreach ( (array) $terms as $term )
    				echo "\t<option value='{$term->slug}' " . selected( $current, $term->slug, false ) . ">{$term->name}</option>\n";
    
    			echo '</select>';
    		}
    
    		echo '<input type="submit" id="searchsubmit" class="searchsubmit" value="'. esc_attr( $instance['button_text'] ) .'" />
    		<div class="clear"></div>
    	</form>';
    
    		echo $after_widget;
    
    	}
    
    	function update( $new_instance, $old_instance ) {
    		return $new_instance;
    	}
    
    	function form( $instance ) {
    		
    		$instance = wp_parse_args( (array) $instance, array(
    			'title'       => '',
    			'button_text' => __( 'Search Properties', 'agentpress-listings' )
    		) );
    
    		global $_agentpress_taxonomies;
    
    		$listings_taxonomies = $_agentpress_taxonomies->get_taxonomies();
    		$new_widget = empty( $instance );
    
    		printf( '<p><label for="%s">%s</label><input type="text" id="%s" name="%s" value="%s" style="%s" /></p>', $this->get_field_id( 'title' ), __( 'Title:', 'agentpress-listings' ), $this->get_field_id( 'title' ), $this->get_field_name( 'title' ), esc_attr( $instance['title'] ), 'width: 95%;' );
    		?>
    		<h5><?php _e( 'Include these taxonomies in the search widget', 'agentpress-listings' ); ?></h5>
    		<?php
    		foreach ( (array) $listings_taxonomies as $tax => $data ) {
    
    			$terms = get_terms( $tax );
    			if ( empty( $terms ) )
    				continue;
    
    			$checked = isset( $instance[ $tax ] ) && $instance[ $tax ];
    
    			printf( '<p><label><input id="%s" type="checkbox" name="%s" value="1" %s />%s</label></p>', $this->get_field_id( 'tax' ), $this->get_field_name( $tax ), checked( 1, $checked, 0 ), esc_html( $data['labels']['name'] ) );
    
    		}
    		
    		printf( '<p><label for="%s">%s</label><input type="text" id="%s" name="%s" value="%s" style="%s" /></p>', $this->get_field_id( 'button_text' ), __( 'Button Text:', 'agentpress-listings' ), $this->get_field_id( 'button_text' ), $this->get_field_name( 'button_text' ), esc_attr( $instance['button_text'] ), 'width: 95%;' );
    	}
    }
    September 4, 2015 at 3:53 pm #164616
    brent s
    Member

    I have resolved this and figured out how to make it work.

    September 6, 2015 at 11:16 am #164755
    Tom
    Participant

    Perhaps you could share your solution with the forum and mark your thread "resolved"?


    Choose your next site design from over 350 Genesis themes.
    [ Follow me: Twitter ] [ Follow Themes: Twitter ] [ My Favourite Webhost ]

    September 6, 2015 at 12:25 pm #164757
    brent s
    Member

    Sorry, I didn't realize to do that. I installed search everything plugin and made the search selections in the plugin.

  • Author
    Posts
Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Modify Search Function’ is closed to new replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2025 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble