Created
April 19, 2017 18:59
-
-
Save akkord87/0e71f324337e5b0bc54dc7e0858b6746 to your computer and use it in GitHub Desktop.
Убрать slug произвольного типа записей из URL WordPress
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Тип записи services | |
function true_post_type_rewrite() { | |
global $wp_rewrite; | |
// перезаписываем URL | |
// параметры add_rewrite_tag('%название_тега%', '%маска_символов%', '%url_параметр%') | |
$wp_rewrite -> add_rewrite_tag("%services%", '([^/]+)', "services="); | |
$wp_rewrite -> add_permastruct('services', '%services%' ); | |
} | |
add_action( 'init', 'true_post_type_rewrite'); | |
function true_rewrite_conflicts( $request ) { | |
if(!is_admin()) { | |
// перечисляем типы записей с подобной структурой пермалинков | |
$request['post_type'] = array('services', 'post', 'page', 'blog', 'doctors'); | |
} | |
return $request; | |
} | |
add_filter( 'request', 'true_rewrite_conflicts' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment