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

public custom posts not showing in my wordpress plugin

You are not seeing or that your function (test_get_post_types) is not returning the custom post types because if you look at the Carbon Fields source code, carbon_fields_register_fields is run by Carbon_Fields\Loader\trigger_fields_register() which is hooked on init with the priority 0. (See lines 113 and 44 in carbon-fields/core/Loader/Loader.php) So that means, by the time your lnpa_attach_theme_options … Read more