WordPress.org

Ready to get started?Download WordPress

Forums

Query Multiple Taxonomies
[resolved] Base_url in combination with archive-{post-type} and no matches. (3 posts)

  1. koenmeloen
    Member
    Posted 1 year ago #

    Thanks for the great plugin! It does (almost) exactly what I need. But there is one issue. I use the plugin on two cpt archive pages. I use the code in y functions.php below to add the post-type name to the url

    function my_qmt_base_url() {
    	if ('activiteiten' == get_post_type()){
    		if('activiteiten' == get_post_type()){
    		return '../activiteiten';
    		}
    	}
    	else if ('arrangementen' == get_post_type()){
    		if('arrangementen' == get_post_type()){
    		return '../arrangementen';
    		}
    
    	}
    }
    add_filter( 'qmt_base_url', 'my_qmt_base_url' );

    This works fine in all occasions except one. When the result is no matches, the post-type value is also empty. Changing the dropdown to other values will redirect to http://localhost/?activiteittypen=binnen&doelgroepen=bedrijven instead of http://localhost/waddenfun/activiteiten/?activiteittypen=binnen&doelgroepen=kinderen.

    The code in my functions.php doesn't work anymore because there is no matching post-type. I think the solution is probably quite simple, but I can't seem to solve it...

    Does anyone have a suggestion how to solve this?

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

  2. koenmeloen
    Member
    Posted 1 year ago #

    If somebody might have the same issue as I had. I managed to solve it. I changed ('cpt' == get_post_type() to is_archive('cpt') and it worked. (and removed the double statements...)

  3. koenmeloen
    Member
    Posted 1 year ago #

    Forget above. That doesn't work. A managed to get it working with this code:
    function my_qmt_base_url() {
    $url = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
    if (false !== strpos($url,'cpt-1')) {
    $base = '../cpt-1';
    } else if (false !== strpos($url,'cpt-2')){
    $base = '../cpt-1';
    }
    return $base;
    }

    If you use cpt's with an archive-page like archive-cpt.php the above code searches for the cpt name in the current page url. When there is a match the base_url gets the name of the cpt. The categories can't contain the name of to avoid a match on a page with different cpt.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic