Answer the question
In order to leave comments, you need to log in
Custom Post Type (PODs framework) – slug modification drive 404 / Not found?
Hello , I'm using the
PODs framework for WP.
Created several custom post types and linked them together.
There is a need to reflect this relationship in the link structure (slug).
Example: domain/custom-post1/custom-post2/post-title
In connection with this, I created a costume function of the following form:
<?php
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 );
?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question