Using a variable in page permalink

As I said, the permalink changes from YEAR_NAME to 2023, but the link gets 404 error Yes, and it’s because the post slug no longer matched the value in the database (in the wp_posts table, column post_name), hence the permalink URL became invalid and WordPress displayed a 404 error page. So you need to add … Read more

WordPress not remembering old slugs for pages

WordPress keeps track of post slug change with wp_check_for_changed_slugs() function. The old slugs are saved in wp_postmeta table with _wp_old_slug meta_key and later redirects to current URL with wp_old_slug_redirect() function. That’s why even after changing a post’s slug, you get redirected to the correct post. However, WordPress doesn’t do this by default with pages (or … Read more

Can you customize the automatic permalink population on new posts?

you can use the post_type_link hook. and then add a custom rewrite rule to your register_post_type function: function replace_post_link( $post_link, $id = 0 ){ $post = get_post($id); $post_type = get_post_type( $id ); if( is_object( $post ) && $post_type == ‘events’ ){ $custom_date = get_field(‘YOUR_CUSTOM_FIELD’); return str_replace( ‘%custom_date%’ , $custom_date, $post_link ); } return $post_link; } … Read more

Pages resolve at different URLs (different capitalizations)

Have you moved servers recently? In years past, Windows servers always treated them differently than on unix servers. Barring that, you can edit your .htaccess file to convert all URLs to lowercase. Here’s a guide editing depending if you have access to httpd.conf file or not; https://www.rewriteguide.com/apache-enforce-lower-case-urls/ As suggested by @Rup, a canonical URL should … Read more