admin管理员组文章数量:1122846
First, I thought I was going crazy and then after additional troubleshooting, it turns out I'm not!
So, I wanted to create a page called 2017, but every time I create a page that begins with a number WordPress appends a "-2" at the end.
I thought it was something in my theme or some images I had that already had the same name, so I tried all kinds of weird numbers that I definitely wasn't using other places and WordPress still appends a "-2" at the end.
Then I figured, ok, so let's disable my theme (enabled the WordPress default) and plugins to isolate the issue...the issue persisted.
Nothing is in the trash, there are no matching post or page names (not even images)
Finally, I was like, let me try this on another site - different images, different theme, different plugins, different everything...the issue persisted.
So, now I think this is a WordPress thing. Is there a way to fix this?
Basically, to reproduce try and create a page that starts with a number - could be 2005, 1999, or 2017 - the only thing I have noticed is that it has to start with a number.
Am I missing something?
First, I thought I was going crazy and then after additional troubleshooting, it turns out I'm not!
So, I wanted to create a page called 2017, but every time I create a page that begins with a number WordPress appends a "-2" at the end.
I thought it was something in my theme or some images I had that already had the same name, so I tried all kinds of weird numbers that I definitely wasn't using other places and WordPress still appends a "-2" at the end.
Then I figured, ok, so let's disable my theme (enabled the WordPress default) and plugins to isolate the issue...the issue persisted.
Nothing is in the trash, there are no matching post or page names (not even images)
Finally, I was like, let me try this on another site - different images, different theme, different plugins, different everything...the issue persisted.
So, now I think this is a WordPress thing. Is there a way to fix this?
Basically, to reproduce try and create a page that starts with a number - could be 2005, 1999, or 2017 - the only thing I have noticed is that it has to start with a number.
Am I missing something?
Share Improve this question edited Jan 9, 2018 at 19:36 CalvT 3342 gold badges8 silver badges15 bronze badges asked Jan 9, 2018 at 14:57 Josh RodgersJosh Rodgers 1,1731 gold badge16 silver badges42 bronze badges1 Answer
Reset to default 13Within the wp_unique_post_slug
function, checks are made to "Prevent new post slugs that could result in URLs that conflict with date archives." Here's the relevant code from line 3812 from wp-includes/post.php
// Prevent new post slugs that could result in URLs that conflict with date archives.
$post = get_post( $post_ID );
$conflicts_with_date_archive = false;
if ( 'post' === $post_type && ( ! $post || $post->post_name !== $slug ) && preg_match( '/^[0-9]+$/', $slug ) && $slug_num = intval( $slug ) ) {
$permastructs = array_values( array_filter( explode( '/', get_option( 'permalink_structure' ) ) ) );
$postname_index = array_search( '%postname%', $permastructs );
/*
* Potential date clashes are as follows:
*
* - Any integer in the first permastruct position could be a year.
* - An integer between 1 and 12 that follows 'year' conflicts with 'monthnum'.
* - An integer between 1 and 31 that follows 'monthnum' conflicts with 'day'.
*/
if ( 0 === $postname_index ||
( $postname_index && '%year%' === $permastructs[ $postname_index - 1 ] && 13 > $slug_num ) ||
( $postname_index && '%monthnum%' === $permastructs[ $postname_index - 1 ] && 32 > $slug_num )
) {
$conflicts_with_date_archive = true;
}
}
本文标签: permalinksPage begins with numberWordPress adds 2
版权声明:本文标题:permalinks - Page begins with number, WordPress adds 2 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736283885a1927116.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论