0

I am using PODs custom post type and I have created bi-relatation between two post types. My idea is to get a custom slug when there is a relation between two custom post types like: /custom-post-slug1/custom-post-slug2/post-title

So I have created this function:

function custom_post_slug ( $post_link, $post ) {

/* Pulling the relation post slug */
$quote_author = get_post_meta($post->ID, 'quote_author', true);
$quote_author['post_name'];

/* Condition for 'quote' post type */
if ( 'quote' != $post->post_type || 'publish' != $post->post_status ) {
    return $post_link;
}
/* Modifying slug */ 
$post_link = str_replace( '/' . $post->post_type . '/', '/' . $quote_author['post_name'] . '/' . $post->post_type . '/', $post_link );
return $post_link;

} add_filter( 'post_type_link', 'custom_post_slug', 10, 3 );

The function does work (I could see that slug got modified, but I am getting 404/not found on post pages....). Am I missing something?

Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.