• Resolved jedifunk

    (@jedifunk)


    Another topic…

    What I’m trying to acheive is this.

    CPT = resources
    Tax1 = resource_type | tax1_term = white-papers
    Tax2 = industry | tax2_term = enterprise

    1. example.com/resources = either a Page titled Resources OR a CPT archive page called resources. I don’t care which. If its a page, I’ll create page-resources.php and add content. If its a CPT archive, I’ll just create an archive-resources.php and add my content there.

    2. Then I’d like example.com/resources/type/white-papers which should be a taxonomy archive using taxonomy-resource_type.php. On this archive should be a dropdown to filter the white-papers by industry.

    3. The third layer would be example.com/resources/type/white-papers/industry/enterprise.

    4. Ideally, the actual CPT post would reside at example.com/resources/type/white-papers/the-post but I can live with example.com/resources/the-post if necessary.

    I am able to acheive variations of these, but on all 3.

    I can get the CPT to work correctly, in that it will load either a page or the CPT archive. But then the taxonomies 404.

    I can switch things around and get the taxonomies to work, both /type/white-papers/ and type/white-papers/industry/enterprise but then the CPT archive page loads as is_home.

    Thoughts?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter jedifunk

    (@jedifunk)

    Figured it would help to see the CPT and Tax registers…

    For the CPT: I’m showing it with some items commented out, because these work or don’t work depending on the scenario.

    'taxonomies' => array( 'resource_type', 'industry' ),
    //'has_archive' => 'resources',
    'query_var' => true,
    'rewrite' => array(
         //'slug' => 'resources',
         'with_front' => false
    ),

    Tax1 (resource_type):

    'query_vars' => 'type',
    'rewrite' => array( 
         'slug' => 'type',
         'with_front' => false
    )
    register_taxonomy( 'resource_type', array( 'resources' ), $args );

    Tax2 (industry):

    'rewrite' => array(
         'with_front' => false
    )
    register_taxonomy( 'industry', array( 'post', 'resources', 'event', 'media_article' ), $args );

    Also note that with_front => false is set because I have a custom structure in play.

    Plugin Author Jonathandejong

    (@jonathandejong)

    Hi @jedifunk.

    1. For the best compatibility with BTF you should use the cpt-archive template.

    2. I think the best solution would be to keep using the cpt-archive even here. If you need different layouts etc. I suggest you use conditional checks along with including different components. Here you can also place the dropdown module to let users keep filter down on industry as well as resources. If you don’t want them to be able to filter the resource (maybe you’re directing them directly into a resource from another place in your website) you can just hide the resource dropdown using CSS (that’s the easiest way without messing too much with the code).

    3. The third layer would be correct with the above.

    4. BTF do not attempt to mess with the permalink of a single post. That’s sort of beyond the scope of what BTF is supposed to do. Unfortunately WordPress Core only seem to support core categories in the permalinks. I think you can create your own rewrite rules if you really want to but it’s a bit too complicated for me to go into ?? Here’s something similar that might get you started: https://gist.github.com/kasparsd/2924900

    Thread Starter jedifunk

    (@jedifunk)

    @jonathandejong

    This is great! Much easier than trying to get the taxonomy archive template to render via a rewrite!

    Thanks so much!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Rewrite with CPT archive’ is closed to new replies.