Support » Plugin: CPT-onomies: Using Custom Post Types as Taxonomies » Fix for CPT-onomy feeds and pagination

  • ResolvedPlugin Author Rachel Cherry


    Hey gang. If your CPT-onomy feeds or pagination isn’t working, it’s because they require custom rewrite rules and… well… honestly, I’m not really sure why this hasn’t been fixed before now.

    I’m trying my best to get an update out soon but, in the meantime, here’s the fix:

    Replace lines 860-868 of manager.php with the following code:

    // replace the variables ($post_type and $term)
    $cpt_onomy_archive_slug = str_replace( array( '$post_type', '$term_slug', '$term_id' ), array( $taxonomy, '([^/]+)', '([^/]+)' ), $cpt_onomy_archive_slug );
    // get rid of any slashes at the beginning AND end
    $cpt_onomy_archive_slug = preg_replace( '/^([\/]+)/', '', $cpt_onomy_archive_slug );
    $cpt_onomy_archive_slug = preg_replace( '/([\/]+)$/', '', $cpt_onomy_archive_slug );
    // add feeds rewrite
    add_rewrite_rule( $cpt_onomy_archive_slug . '/feed/(feed|rdf|rss|rss2|atom)/?$', 'index.php?'.$taxonomy . '=$matches[1]&feed=$matches[2]&cpt_onomy_archive=1', 'top' );
    add_rewrite_rule( $cpt_onomy_archive_slug . '/(feed|rdf|rss|rss2|atom)/?$', 'index.php?'.$taxonomy . '=$matches[1]&feed=$matches[2]&cpt_onomy_archive=1', 'top' );
    // adding pagination rewrite
    add_rewrite_rule( $cpt_onomy_archive_slug . '/page/?([0-9]{1,})/?$', 'index.php?'.$taxonomy . '=$matches[1]&paged=$matches[2]&cpt_onomy_archive=1', 'top' );
    // add base URL rewrite
    add_rewrite_rule( $cpt_onomy_archive_slug . '/?$', 'index.php?'.$taxonomy . '=$matches[1]&cpt_onomy_archive=1', 'top' );

  • The topic ‘Fix for CPT-onomy feeds and pagination’ is closed to new replies.