WordPress.org

Ready to get started?Download WordPress

Forums

Query Multiple Taxonomies
Base URL problem (8 posts)

  1. tiedemies
    Member
    Posted 2 years ago #

    I use QMT for one specific post type and the widget appears only on the said post type's archive page. I would need the base URL to be /my-custom-post-type/ but can't get it working.

    The closest I've gotten have been with this code:

    function my_qmt_base_url() {
    	return get_page_link( 3 );
    }
    add_filter( 'qmt_base_url', 'my_qmt_base_url' );

    The resulting URL itself is what I want, but the filtering won't work. It shows all posts regardless of their taxonomies and the widget does not "save" the chosen taxonomies into the dropdowns.

    What could be going wrong?

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

  2. Axenstar86
    Member
    Posted 2 years ago #

    A came to the same problem. I have several CPTs and need the URLs to be in the structure /my-custom-post-type/+QMT-Query-String+/.

    Is there any solution available?

  3. Paglalakbay
    Member
    Posted 2 years ago #

    Hi Guys,

    Create a custom post type archive template:

    archive-{post_type}.php

    http://codex.wordpress.org/Template_Hierarchy#Custom_Post_Types_display

    and then set the name of the CPT as the base url.

    function my_qmt_base_url() {
    	return '../post-tpe-name';
    }
    add_filter( 'qmt_base_url', 'my_qmt_base_url' );


    edit:

    Don't forget to remove pages that have the same name as the custom post type so pagination and the archive template works.

  4. Axenstar86
    Member
    Posted 2 years ago #

    thanks for the reply.

    however it doesn't work for me. After sending the query I get a 404 Error.

    The page name is another than the CPT name.

    I'm additionally using the plugin "Post Types - Taxonomies intersections" to dsiplay single taxonomie queries in a nice way (cpt/tax/term/).
    I thought it maybe causes some problems when running it together with query-multiple-taxonomies. But deactivating it doesn't bring any difference.

    Regards

    EDIT: OK I Forgot to add 'has_archive=true' when registering the cpt. seems to work now, thanks a lot.

  5. thhhhh
    Member
    Posted 1 year ago #

    I've got five custom post types on my site with many shared taxonomies, but I was hoping to accomplish something similar to this.

    I want to have my site check what post type archive page I am looking at, and then insert that post type at the head of my query.

    Here's what I've got in terms of code... using version 1.62 of the plugin.

    if ( is_post_type_archive() ) {
    
        $CPTquery = get_post_type( $post->name );
    }
    
    function my_qmt_base_url() {
    	return '../?post_type=' . $CPTquery;
    }
    add_filter( 'qmt_base_url', 'my_qmt_base_url' );

    Despite this code, I'm not seeing the query string affected at all. Any ideas?

  6. thhhhh
    Member
    Posted 1 year ago #

    Should this be in functions.php or on the archive page? Currently its in functions.

  7. thhhhh
    Member
    Posted 1 year ago #

    Anyone?

  8. camilodelvasto
    Member
    Posted 1 year ago #

    thhhhh: Don't really have a clue of what may work for you, but I can share you what I did.
    I created a CPT named "autos" and created an archive-autos.php page. I added this code in the functions.php file of my theme:

    function my_qmt_base_url( $base ) {
        return get_bloginfo('home').'/autos/';
    }
    add_filter( 'qmt_base_url', 'my_qmt_base_url' );

    That (and some other changes) worked for me. Hope that helps!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic