How do I disable the changing of the permalink for published posts (for non-admin)?

You could do something like the following, this should go in your Child Theme’s functions.php or if not using a Child Theme then add to a custom plugin: function hide_permalink_metabox( $is_post_edit_page ) { if ( !current_user_can(‘update_core’) ) { // allows Admins to edit the permalink echo ‘<style> div#edit-slug-box {display:none!important;} </style>’; } You may need to … Read more

Adding tag slug to post permalink

You need to add a new tag (e.g. %tag%) that you can use in post links. One possibility is to use the add_rewrite_tag() function. Then use the post_link filter to replace the %tag% in the link with the appropriate value. Finally, change the post link structure in the settings. Settings -> Permalinks -> Custom Structure: … Read more

Duplicate Content Issue with WordPress Permalink Structure and Primary Categories

function get_current_post_ID() { $postid = get_queried_object_id(); $post_url = get_permalink( $postid ); //wp_redirect( $post_url ); if( has_category(”, $postid) && urldecode(‘https://’.$_SERVER [‘HTTP_HOST’].$_SERVER [‘REQUEST_URI’]) != $post_url ) : wp_redirect( $post_url, 308 ); exit(); endif; } add_action( ‘template_redirect’, ‘get_current_post_ID’ );

How to add .html extension only to pages without child pages?

I think you can achieve the desired functionality by selectively adding the .html extension to specific pages using a custom rewrite rule and the page_link filter. // Add a custom rewrite rule to handle pages with .html extension function custom_html_page_rewrite_rule() { add_rewrite_rule( ‘^([^/]+)(\.html)/?$’, ‘index.php?pagename=$matches[1]’, ‘top’ ); } add_action(‘init’, ‘custom_html_page_rewrite_rule’, 10); // Filter page links to … Read more

How to remove parent slugs from child pages permalinks?

To remove parent slugs from child pages’ permalinks in WordPress and avoid the 404 error, you’ll need to modify your code and add some rewrite rules. First, modify your code to remove the parent slug from the child page’s permalink: function my_pages_permalink($link, $post) { if ($post->post_parent) { $parent = get_post($post->post_parent); $link = trailingslashit(home_url($parent->post_name)) . $post->post_name … Read more