Dynamically Updating CPT Permalinks
-
We’re attempting to use this to make two interlocking CPTs, which are updated through
wp_insert_post()
and an API call.Community CPT:
<%ctax_states%>/<%ctax_cities%>/%postname%
Design CPT:<%ctax_states%>/<%ctax_cities%>/<%ctax_communities%>/%postname%
Note that the paths must be very similar for both to follow the existing site structure and SEO.
It looks like the redirects are forcing us to one page, and a very wrong page at that:
/fl/vero-beach/vero-lake-estates-32967/wilmington-60.html /northern-ky/ /fl/vero-beach/vero-lake-estates-32967/willow-32.html /northern-ky/ /fl/vero-beach/vero-lake-estates-32967/sierra.html /northern-ky/ /fl/vero-beach/vero-lake-estates-32967/sequoia.html /northern-ky/
We attempted the hooks to disable redirects, but they disabled all and essentially stopped the plugin from working. Any advice?
Example Community CPT
register_post_type()
$args = array( 'label' => __( 'Community', 'twentythirteen' ), 'description' => __( 'Community page templates', 'twentythirteen' ), // UI Labels 'labels' => array( 'name' => _x( 'Community', 'Post Type General Name', 'twentythirteen' ), 'singular_name' => _x( 'Community', 'Post Type Singular Name', 'twentythirteen' ), 'menu_name' => __( 'Community', 'twentythirteen' ), 'parent_item_colon' => __( 'Parent Community', 'twentythirteen' ), 'all_items' => __( 'All Communities', 'twentythirteen' ), 'view_item' => __( 'View Community', 'twentythirteen' ), 'add_new_item' => __( 'Add New Community', 'twentythirteen' ), 'add_new' => __( 'Add New', 'twentythirteen' ), 'edit_item' => __( 'Edit Community', 'twentythirteen' ), 'update_item' => __( 'Update Community', 'twentythirteen' ), 'search_items' => __( 'Search Communities', 'twentythirteen' ), 'not_found' => __( 'Not Found', 'twentythirteen' ), 'not_found_in_trash' => __( 'Not found in Trash', 'twentythirteen' ), ), // Features this CPT supports in Post Editor 'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'comments', 'revisions', ), 'hierarchical' => false, 'public' => true, 'show_ui' => true, 'show_in_menu' => true, 'show_in_nav_menus' => true, 'show_in_admin_bar' => true, 'menu_position' => 5, 'can_export' => true, 'has_archive' => false, 'menu_icon' => 'dashicons-admin-multisite', 'exclude_from_search' => false, 'publicly_queryable' => true, 'capability_type' => 'post', 'taxonomies' => array('states', 'cities'), // 'rewrite' => false, 'rewrite' => array('slug' => 'community', 'with_front' => false), ); register_post_type( 'community', $args );
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Dynamically Updating CPT Permalinks’ is closed to new replies.