• Resolved smdever

    (@smdever)


    Love this plugin!!! Am trying out the development version.

    One question though – I am not displaying the widget on my home page, it’s on a page called “directory” But when I click “reset” after running a query, it sends me to the home page. Is there any way to specify which page the “reset” button will send you to?

    Thanks.

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author scribu

    (@scribu)

    Just add this code in your functions.php:

    function my_qmt_base_url() {
    	return get_page_link( YOUR_PAGE_ID );
    }
    add_filter( 'qmt_base_url', 'my_qmt_base_url' );
    Thread Starter smdever

    (@smdever)

    Thank you so much for the speedy response, worked like a charm.

    I hope I’m not being too greedy, but… here’s one more…

    Actually, I run two different searches using your widget on two different pages “Events” and “Directory”.

    Is there any way in this version to customize the reset per widget, or per custom post type? So when I run a search on the Events page (which searches custom post type = Events), it resets to the Event page? And when I run a search on “Directory” (searching custom post type = Listing), it resets to the Directory page?

    Plugin Author scribu

    (@scribu)

    You will have to choose the page based on which taxonomy is queried, not on a particular post type. This is because a taxonomy can be associated to multiple post types.

    Something like this:

    function my_qmt_base_url( $url ) {
    	// Get the list of queried taxonomies
    	$tax_names = array_keys( qmt_get_query() );
    
    	// Choose page ID
    	if ( in_array( 'tax_a', $tax_names ) )
    		$page_id = 1;
    	elseif ( in_array( 'tax_b', $tax_names ) )
    		$page_id = 2;
    	// etc.
    
    	return get_page_link( $page_id );
    }
    add_filter( 'qmt_base_url', 'my_qmt_base_url' );
    Thread Starter smdever

    (@smdever)

    Hmm. Both snippets worked fine in terms of resetting the page to where I wanted it to go.

    However, when I try to submit the query, I get the 404 Not Found error message.

    When I remove the snippet, the query function works fine again.

    Any ideas? Sorry to be such a pest about this, and thanks so much for all the help you’ve already given.

    Plugin Author scribu

    (@scribu)

    Right, forgot about that.

    I’ve added a dedicated filter for this in the dev version.

    Just replace add_filter( 'qmt_base_url' with add_filter( 'qmt_reset_url'.

    Thread Starter smdever

    (@smdever)

    Well, that fixes the the problem with searching, but now “reset” sends me back to my home page again.

    Did I do replace the correct string of code? The full line of text I used was:

    add_filter( 'qmt_reset_url', 'my_qmt_base_url' );

    Look, you’ve been so helpful, but if answering these questions isn’t giving you useful feedback as you develop the plugin, please don’t worry about it. I know the plugin’s still in development, and I can do my best to be patient until its ready ?? Just asking in case it’s an easy one for you to answer and/or gives you useful feedback.

    Plugin Author scribu

    (@scribu)

    I forgot to mention that you have to re-download the development version.

    but if answering these questions isn’t giving you useful feedback as you develop the plugin

    On the contrary! ??

    Thread Starter smdever

    (@smdever)

    Yay! Works perfectly.

    Now I just have to get my Widget Logic to play nicely with the QMT function and display the widgets on the search result pages… it doesn’t want to, even when I specify is_tax(A) or is_tax(A)&&is_tax(B)…. but THAT is a topic for another forum.

    Thanks again for all your help!

    Hi Scribu – I really hope I’m posting in the right place this time.

    I’m not sure if you recall, but, I was using the earlier dev version of QMT and had some specific functionality that I needed.

    You helped me to get that all sorted with some filters, but, now I am trying to go ahead and use the newer version, which does things a little differently, and maintain the same functionality.

    Problem is, like the person above, I need to use the post type in order to customize the reset.

    Here is what I have been using for the QMT version I am on:

    //I realize with the new version I don’t need this first function, as I can call it with the widget now——————-//

    function my_qmt_post_type() {
    	global $wp;
    	global $wp_query;
    
        if ( get_query_var('post_type') === 'lesson' ) {
    return 'lesson';
    }
    	if ( get_query_var('post_type') === 'workshop' ) {
    return 'workshop';
    }
    	if ( get_query_var('post_type') === 'howto' ) {
    return 'howto';
    }
    }
    
    add_filter('qmt_post_type', 'my_qmt_post_type');
    
    function my_qmt_base_url($base) {
    	$ptype = get_post_type_object(QMT_Core::get_post_type());
    	$plural = sanitize_title_with_dashes($ptype->label);
    
    	return get_bloginfo('url') . '/' . $plural;
    }
    
    add_filter('qmt_base_url', 'my_qmt_base_url');

    What I have are 3 custom made archives of 3 different custom post types using template_redirect and new rewrite rules.

    The sidebar of each of these custom archives is where the taxonomy drilldown widgets live.

    When drilldown add/remove is clicked it goes to multitax template, where it currently only shows post types from the custom post_type archive page which sent it there. It then resets back to that custom post_type archive.

    Multitax is using get_query_var to know what header to show and what sidebar QMT widget to bring in ( also according to post_type )

    All three of my custom post types ( lessons, howtos, workshops ) share the same subsets of taxonomies … art subject, academic subject etc.

    When filtering lessons, I need to be able to stay within the lesson post type and filter by multiple taxonomies.

    I can do that now, but, would like to take advantage of the newer code to regain my category functionality etc.

    Is there any way to do this reset now?

    Plugin Author scribu

    (@scribu)

    With the latest development version (1.3-alpha3), this should work for you:

    function my_qmt_base_url( $url ) {
    	$ptype = get_post_type_object(get_query_var('post_type'));
    	$plural = sanitize_title_with_dashes($ptype->label);
    
    	return get_bloginfo('url') . '/' . $plural;
    }
    add_filter( 'qmt_base_url', 'my_qmt_base_url' );

    Nice. I’m going to give it a shot right now. Thanks as usual Scribu ??

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘[Plugin: Query Multiple Taxonomies] customize reset’ is closed to new replies.