Custom Post Type Taxonomy Permalinks
-
I am having a very specific issue on permalinks.
I have a custom post type and a taxonomy.
Using the function below sorted out the correct structure of the taxonomy permalinks.function phototype_permalink($permalink, $post_id, $leavename){ if (get_option('permalink_structure') != ''){ $post = get_post($post_id); $rewritecode = array( '%postname%' ); if (strpos($permalink, '%postname%') !== FALSE){ $terms = wp_get_object_terms($post->ID, 'phototype'); if (!is_wp_error($terms) && !empty($terms) && is_object($terms[0])) $phototype = $terms[0]->slug; else $phototype = ''; } $rewritereplace = array( $phototype ); $permalink = str_replace($rewritecode, $rewritereplace, $permalink); } return $permalink; } add_filter('post_type_link', 'phototype_permalink', 1, 3);
then adding to args this:
'rewrite' => array('slug' => '%postname%'),
Regular posts also fit themselves to the new structure.
However I am getting 404 error on pages. The wierdest thing is that I am not getting this error on pages with parents.For ex: I am getting 404 error here: domain.com/products-page/
and here not: domain.com/products-page/your-account/Any idea?
- The topic ‘Custom Post Type Taxonomy Permalinks’ is closed to new replies.