Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I read this topic and I have tested the solution and it works for me but I have encountered a problem.

I have Custom Taxonomy named Regione and those hierarchical categories inside it:

https://copy.com/hzp8W3oDNWFSJ1Ec

Now I add a post into my custom post type Struttura and I obtain this permalink:

/strutture/umbria/perugia/lisciano-niccone/agriturismo-davide/

where strutture is basename and agriturismo-davide is postname

The permalink is what I want but it works only if I select the sub-sub-parent-category.

If I select parent-category AND sub-parent-category AND sub-sub-parent-category the permalink becomes:

/strutture/umbria/agriturismo-davide/

and I obtain a 404 error. I lost sub-parent-category and sub-sub-parent-category from permalink.

Is it a problem for search query?

I try to do this query inside single-struttura.php:

$tax = 'regione';
$terms = get_terms($tax);
if ($terms) {
    $args=array(
        'post_type' => 'struttura',
        'regione' => 'lisciano-niccone',
    );
    $my_query = null;
    $my_query = new WP_Query($args);
    if( $my_query->have_posts() ) {
        echo 'List of '.$post_type . ' where the taxonomy '. $tax . '  is '. $my_query->query_vars['regione'];
        while ($my_query->have_posts()) : $my_query->the_post(); ?>
            <br><?php the_title();
        endwhile;
    }
    wp_reset_query();
}

and it works. I try to change lisciano-niccone (sub-sub-parent-category) with perugia (sub-parent-category) or umbria (parent-category) and it works too.

Is it the best solution?

How I remove the basename from permalink?

share|improve this question
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.