Change post-name when inserting new Post if Specific Category is selected in WP

You can use the wp_insert_post_data filter, and check the post_category array for your category ID. (If $update is false, you’ll know it’s a new post being added, not an existing post being edited.) Something like this should work. add_filter( ‘wp_insert_post_data’, ‘wpse414180_maybe_change_slug’, 10, 4 ); /** * Changes the slug on posts in the Poetry category. … Read more

WordPress Multisite Network Shared Custom Post from Main Site using single-CPT.php

I seem to have solved it with the following code which I cobbled together from other answers after searching last 24hrs. It gave an error until I removed the restore_current_blog at the end of the function. As this should only be used by the singular page for the custom post type, I am hoping, it … Read more