Forum Replies Created

Viewing 1 replies (of 1 total)
  • Thread Starter martin0

    (@martin0)

    thanks! @bcworkz i cand do it with the next:

    function custom_rewrite_basic() {
      add_rewrite_rule('mysite.com/mycpt/myterm', 'index.php?post_type=mycpt&&mytax=myterm', 'top');
    }
    add_action('init', 'custom_rewrite_basic');

    In archive-mycpt.php i use is_tax() and post_type_archive_title, for customizing it.

    To add i do a redirect if the user attempt to go to mysite.com/mytax/myterm , that is becasue there display all custom post type with the taxonomy term and i dont want that, it will be a mess of information, so i do this:

    function redireccion() {
        if ( is_tax('myterm') && !is_post_type_archive() ) {
            wp_redirect( home_url(), 301 );
            exit();
        } 
    }
    add_action( 'template_redirect', 'redireccion' );
    • This reply was modified 8 years, 10 months ago by martin0.
Viewing 1 replies (of 1 total)