Hi…. I’m having a small issue migrating my blog posts over to my new website… Basically, the new website is adding an extra zero (0) where it’s not needed in the date… So for example, here is a link to a current blog post:
https://www.test.com/blog/2017/4/4/casualties-of-war
And here is how my new site is structuring the same blog post:
https://www.test.com/blog/2017/04/04/casualties-of-war
For the month & day it’s adding an extra zero (0) where it’s not necessarily needed….
Is there an easy way to remove this? I cannot seem to find this in the permalinks settings page.
Thank you much!
T
]]>Anyways, you could follow the instructions on this link to get this done:
https://wordpress.stackexchange.com/questions/65546/removing-leading-zeros-from-custom-permalink-structure
function t5_strip_leading_zeros_in_url( $url )
{
// no pretty permalinks
if ( ! $GLOBALS['wp_rewrite']->get_month_permastruct() )
{
return $url;
}
return str_replace( '/0', '/', $url );
}
add_filter( 'month_link', 't5_strip_leading_zeros_in_url' );
add_filter( 'day_link', 't5_strip_leading_zeros_in_url' );
add_filter( 'the_permalink', 't5_strip_leading_zeros_in_url' );
]]>