@你可以添加yogu 在permalink中获取所需的结构。site-url.com/22 (without ?p=)
对于特定帖子,您可以添加以下函数并为其添加特定条件:
add_filter( \'post_link\', \'custom_permalink\', 10, 3 );
function custom_permalink( $permalink, $post, $leavename ) {
// For shortlink condition
if ( \'Shortlink Condition here\' ) {
$permalink = trailingslashit( home_url(\'/\'. $post->ID .\'/\' ) );
}
return $permalink;
}
add_action(\'generate_rewrite_rules\', \'custom_rewrite_rules\');
function custom_rewrite_rules( $wp_rewrite ) {
// This rule will will match the post id in %post_id% struture
$new_rules[\'^([^/]*)-([0-9]+)/?\'] = \'index.php?p=$matches[2]\';
$wp_rewrite->rules = $new_rules + $wp_rewrite->rules;
return $wp_rewrite;
}