• Resolved Jim Reekes

    (@reekes)


    This is a followup to my question “permalink for custom posts”. That’s working correctly. My custom post type (library) appear under this path:

    mydomain.com/learn/library/some-custom-post

    What I want to change is where the archives appear. Currently it’s here at the root of my domain:

    mydomain.com/library-categories/custom-category

    Instead I’d the archive pages to be at the same level as the custom posts, like this to be:

    mydomain.com/learn/library/library-categories/custom-category

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter Jim Reekes

    (@reekes)

    After further research, it looks like the plugin doesn’t allow for setting the rewrite rules of a taxonomy. Instead I’ve added code to my functions.php file that will set the slug to the path I wanted.

    My feature request would be to allow the taxonomy to be moved from the root to the same URL as the custom posts.

    Plugin Author Cristian Antohe

    (@sareiodata)

    Hi Jim,

    You can filter that via this hook like so:

    
    add_filter('wck_ctc_register_taxonomy_rewrite_arg', 'custom_tax_rewrite',10,2);
    function custom_tax_rewrite($value, $ct_vars){
    
        if($ct_vars['taxonomy'] === 'product'){
            flush_rewrite_rules();
            return array( 'slug' => 'blog/product', 'with_front' => false );
        }
    }
    

    However, it didn’t work for me. It changes the rewrite of the custom taxonomy, however, I get a 404 error when I try to access it.

    That’s because you already have /blog/ as a rewrite for your posts. So basically this won’t work without some other creative rewrite rules custom defined.

    Unfortunately I don’t have a solution for you at this point. Perhaps you could use something else for the rewrite like /blog-archive/ ?

    Thread Starter Jim Reekes

    (@reekes)

    Thanks Cristian, there’s two different problems.

    One is about my custom taxonomy. That’s the /library/ example I describe above. I found it was rather easy (once you find the course code) to define the custom taxonomy to my custom post type. The code allows me to define the slug. The thing I was missing is that the plugin doesn’t support the slug option, and the taxonomy pages would appear at the root. I want them to appear within the same slug as the custom posts (which just seems logical to me when custom taxonomy is attached to a post).

    Anyway…I got all my custom post and custom taxonomies working. That was the /library/ problem.

    The other problem is the /blog/ (which you helped me with in a different thread. I needed to make the change to the WP Settings permalinks to support my /library/ custom post. Your suggestion got that working just as I needed, but had a side effect on the /blog/.

    At first I thought it was working. All my blog posts are in fact within the /blog/ slug as I want. But what I noticed last week is the blog’s main page is no longer the page I created. That slug has been replaced by an archive page.

    My blog’s home page is an actual WP ‘page’ (not a ‘post’) that I designed. It used a shortcode to show the list of blog posts. Now after the changes the /blog/ location is no longer showing the WP page I had created. Looks like WP is now using that slug for the archive permalink instead of the URL to the page I had created.

    I suspect this means I’ll have to create a custom archive template in PHP for my blog posts. That’s unfortunate since it’s so much easier to create pages with the WP UI and my theme, rather than writing PHP code to layout a page.

    Plugin Author Cristian Antohe

    (@sareiodata)

    Unfortunately you’ve hit limitations in the WordPress permalink structures. What you’re describing is default WordPress functionality regarding the /blog issue.

    What you could try is in WCK -> Post Type Creator to edit the Post type so it doesn’t have an archive page. And try again. It might still not work, in which case you’ll have to have a custom php archive page.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘permalink for category and tag archives’ is closed to new replies.