Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function bis_rewrite_cpt_permalinks( $post_link, $post, $leavename, $sample ) {
- if ( ! empty( $post->post_type ) && in_array( $post->post_type, array( 'video_skrn', 'episodes_skrn' ) ) ) {
- if ( $leavename ) {
- $post_link = home_url( "%{$post->post_type}%" );
- } else {
- $post_link = home_url( $post->post_name );
- }
- $post_link = user_trailingslashit( $post_link );
- }
- return $post_link;
- }
- add_filter( 'post_type_link', 'bis_rewrite_cpt_permalinks', 10, 4 );
- function bis_parse_cpt_permalinks( $query ) {
- if ( ! $query->is_main_query() || 2 != count( $query->query ) || ! isset( $query->query['page'] ) ) {
- return;
- }
- if ( ! empty( $query->query['name'] ) ) {
- $query->set( 'post_type', array( 'post', 'page', 'video_skrn', 'episodes_skrn' ) );
- }
- }
- add_action( 'pre_get_posts', 'bis_parse_cpt_permalinks' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement