CPT-onomies: Using Custom Post Types as Taxonomies
need help with custom archive pages/rewrites (5 posts)

  1. abacus718
    Posted 3 years ago #

    Hi. this plugin is great, but i'm having trouble with the archive pages -- not sure why. Here's my situation:

    1) I have these custom post types: attorney, noteworthy-case and practice-area.

    2) Each has a CPTonomy that is related -- you can affiliate cases to attorneys and vice versa; you can affiliate attorneys to practice areas and vice versa, and you can affiliate practice areas to cases and vice versa.

    3) On my notable cases page -- http://tin.abacusdesign.net/noteworthy-cases/-- I want to be able to filter by a) attorney and b) practice type. Ignore practice type for now -- I don't even have the links there for that. But under 'cases by attorney' i have this structure, e.g.http://tin.abacusdesign.net/noteworthy-cases/attorney/jacob-sussman/

    4) I have this in my functions file:

    add_rewrite_rule( '^noteworthy-cases/([^/]*)/?', 'index.php?post_type=noteworthy-cases&attorney=$matches[1]&cpt_onomy_archive=1', 'top' );

    5) when you hit this link:http://tin.abacusdesign.net/noteworthy-cases/attorney/jacob-sussman/ you get a 404. If i type in the url -- http://tin.abacusdesign.net/?post_type=noteworthy-cases&attorney=jacob-sussman&cpt_onomy_archive=1 -- it just takes me to that attorney detail page. it's like it's totally ignoring the rewrite rule in functions (and yes, i have `add_action( 'init', 'tinfulton_rewrites' );

    function tinfulton_rewrites() { the rewrite function here;}`

    Can you help? thanks!


  2. Rachel Carden
    Plugin Author

    Posted 3 years ago #

    Well, the first thing I notice is that your rewrite rule is missing 'attorney'. Try this:

    add_rewrite_rule( '^noteworthy-cases/attorney/([^/]*)/?', 'index.php?post_type=noteworthy-cases&attorney=$matches[1]&cpt_onomy_archive=1', 'top' );

    Be sure to flush your rewrite rules each time you edit them. Flush your rewrite rules by visiting Settings -> Permalinks and clicking “Save Changes”.

    Let me know if that takes care of the problem.

  3. abacus718
    Posted 3 years ago #

    Thanks for the quick response rachel. I added attorneys to the rule (copied what you had) but now it just takes me to the attorney's page -- not to the noteworthy cases page filtered by attorney:


  4. Rachel Carden
    Plugin Author

    Posted 3 years ago #

    Hmm. The answer probably lies in tweaking some of your custom post type settings. Think you could share screenshots of the noteworthy cases and attorney settings?

  5. abacus718
    Posted 3 years ago #

    Hi.. So here are screenshots of the cptonomy setting for notable case: http://tin.abacusdesign.net/tin_cptaxonomy.png

    Jacob sussman has three cases assigned to him (if i edit attorneys and look at the noteworthy case taxonomy).

    I changed the rewrite rule to this (in case the use of attorney was fouling things up):
    add_rewrite_rule( '^noteworthy-cases/counsel/([^/]*)/?', 'index.php?post_type=noteworthycase&attorney=$matches[1]&cpt_onomy_archive=1', 'top' );

    Also, i fixed the fact that the custom post type used to be called notable case and made everything consistent with noteworthycase, but still no dice. Going here and clicking on 'cases by attorney' and selecting 'jacob sussman' takes you to his profile page, not the three cases assigned to him. Any ideas? Thanks!

    P.S. Interestingly, using the archive (cases by year) link and then adding on attorney= doesn't seem to work either: http://tin.abacusdesign.net/2012/?post_type=noteworthycase&attorney=jacob-sussman
    it has the same result -- of taking you to the attorney detail page.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic