Flying Kiwi
Forum Replies Created
Viewing 1 replies (of 1 total)
-
Forum: Plugins
In reply to: rewrite endpoint combined with custom permastructi got it working, what i changed is the following:
changed the add_permastruct args-parameter to include a endpoint-mask:
add_permastruct('mline_products', $permalink_prefix.'/'.$permalink_structure, array('with_front' => false, 'ep_mask' => EP_PRODUCT));also changed the post-type-link filter to only do stuff for the custom-post-type with the custom permastruct. (dno how i could have missed that earlier.) Not sure if this had something to do with the problem i had.
function mline_cpt_products_permalink($permalink, $post) { if(('mline_products' == $post->post_type) && '' != $permalink && !in_array($post->post_status, array('draft', 'pending', 'auto-draft')) ) { $rewritecode = array( '%prodcategory%', '%mline_products%' ); $prodCategory = ''; if ( strpos($permalink, '%prodcategory%') !== false ) { // get the genre: $terms = get_the_terms($post->ID, 'prodcategory'); if( is_wp_error($terms) || !$terms ) { $prodCategory = 'uncategorised'; } else { $prodCategory_obj = array_pop($terms); $prodCategory = $prodCategory_obj->slug; } } $rewritereplace = array( $prodCategory, $post->post_name, ); $permalink = str_replace($rewritecode, $rewritereplace, $permalink); } return $permalink; } add_filter('post_type_link', 'mline_cpt_products_permalink', 10, 2);
Viewing 1 replies (of 1 total)