Skip to content

Changing URLs

Cristi Burcă edited this page May 10, 2013 · 3 revisions

All the code snippets below are meant to be added to your theme's functions.php file.

Change "Reset" URL

If you want to send users to a specific URL when they press the Reset button, you can do it using the 'qmt_reset_url' filter:

<?php
function my_qmt_reset_url( $reset_url ) {
    return 'http://example.com/some-other-url/';
}
add_filter( 'qmt_reset_url', 'my_qmt_reset_url' );

Change base URL

All queries start with a base URL; by default, it's the homepage URL. To change it, you can use the 'qmt_base_url' filter:

<?php
function my_qmt_base_url( $base ) {
    $additional_args = array(
        'orderby' => 'title',
        'order' => 'asc',
    );

    return add_query_arg( $additional_args, $base );
}
add_filter( 'qmt_base_url', 'my_qmt_base_url' );

Here, we made it so that all results are sorted by title, alphabetically.

Other URL manipulations

If you want to be even more specific, you can also change the final URL for each term:

<?php
function my_qmt_url( $url, $query ) {
    // Do something to $url, based on $query
    return add_query_var( 'my_query_var', 'my_value', $url );
}
add_filter( 'qmt_url', 'my_qmt_url', 10, 2 );
Clone this wiki locally