WordPress.org

Ready to get started?Download WordPress

Forums

Query Multiple Taxonomies
Send search keywords to QMT string (1 post)

  1. Rics1983
    Member
    Posted 1 year ago #

    Starting point:
    I've the home page with the wp default searchform and QMT lists on the sidebar.
    My goal is that: when i type a keyword inside the searchform and i hit search, the result of the search will affect also the QMT lists on the sidebar when i get the results page.

    What i achieved till now:
    On the search.php page, where the results of the search query are displayed, i've created a variable "$string_to_qmt" that contains as value a string builded in the right way for QMT:

    ?taxonomy=term+term+term&taxonomy=term+term+term&taxonomy=term"

    I've created a link with this variable, showed together with the result page permalink on the search.php page.
    Clicking on this link, gives me the same results in the same way if I clicked several times on the QMT lists terms.
    So the link it's working.

    Now, to automate this behaviour, i need to send this variable "$string_to_qmt" to QMT core that i modified in this way inside the class QMT_hooks:

    function request( $request ) {
    
    		/* mods */
    		if ( isset( $_GET['s'] ) ) {
    			echo "Searched term: " .$_GET['s'];
    			$sgaRequest = $string_to_qmt;
    		} else {
    			if ( !isset( $_GET['qmt'] ) ) {
    				return $request;
    			} else {
    				$sgaRequest = $_GET['qmt'];
    			}
    		}
    		echo "sgaRequest: " .$sgaRequest;
    		/* mods */
    
    		foreach ( $sgaRequest as $taxonomy => $terms ) {
    			$request['tax_query'][] = array(
    				'taxonomy' => $taxonomy,
    				'terms' => $terms,
    				'field' => 'term_id',
    				'operator' => 'IN',
    			);
    		}
    
    		return $request;
    	}

    This do the following check:
    if i set $_GET['s'] (this means that i did a search using the searchform) get the $string_to_qmt variable that contains the preformatted QMT string.

    What i can't achieve is to send the $string_to_qmt variable, defined into the search.php page, to the core QMT_hooks class.

    I've tried also to define it as global $string_to_qmt, but without success.
    How i can solve this?

    http://wordpress.org/extend/plugins/query-multiple-taxonomies/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic