Thanks! I actually think I figured it out. I left out some of the details as to not confuse you. I’m actually using only with a custom post type called “home-blog-project”
Here’s what I came up with
// Creates a new category automatically for new Home Build posts
function create_home_build_category_on_new_page($post_id) {
$post = get_post($post_id);
if ($post->post_type == 'home-blog-project') {
wp_insert_term(
$post->post_name, // the term
'home_blog_category', // the taxonomy
array(
'description'=> 'Home Build category for '.$post->post_name,
'slug' => $post->slug
)
);
}
}
add_action('edit_post', 'create_home_build_category_on_new_page');
So when you add a new page with custom post type “Home Blog Project” it creates a category automatically with the same slug as the page so my page template will filter the loop with that category. I created the new post type using a plugin called “More Types”.
The only thing that seems weird to me is that the action tag is “edit_post” but it works when you add a post. I assume the only complication will arise if I ever change the slugname for the page, it will create a new category instead of renaming the existing one. One step at a time!