Skip to content

Commit

Permalink
parent-child relationship between 2 types custom post
Browse files Browse the repository at this point in the history
  • Loading branch information
ashrafbd1496 committed Aug 5, 2021
1 parent 0a36f5b commit 13227ba
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,4 +218,18 @@ function philosophy_home_banner_class($class_name){
}
add_filter("philosophy_home_banner_class",'philosophy_home_banner_class');

remove_action('philosophy_after_category_title','text_after_category_title2',8);
remove_action('philosophy_after_category_title','text_after_category_title2',8);

//function for collection custom post type link/url
function philosophy_cpt_slug_link( $post_link, $id ) {
$pid = get_post($id);
if(is_object($pid) && 'chapter' ==get_post_type($id)){
$parent_post_id = get_field('parent_book');
$parent_post = get_post($parent_post_id);
if($parent_post){
$post_link = str_replace('%book%',$parent_post->post_name,$post_link);
}
}
return $post_link;
}
add_filter( 'post_type_link', 'philosophy_cpt_slug_link', 1, 2 );

0 comments on commit 13227ba

Please sign in to comment.