With the help and direction of bosco I was able to get it right!
The code below is a modified version of the answer found here.
function my_enqueue_music_features( $hook_suffix ){
$posts = get_posts( array (
'numberposts' => -1, //this will get all
'post_type' => 'music'
) );
foreach ( $posts as $post ) {
// check the slug and run an update if necessary
$new_slug = sanitize_title( $post->post_title );
if ( $post->post_name != $new_slug )
{
wp_update_post(
array (
'ID' => $post->ID,
'post_name' => $new_slug
)
);
}
}
}
add_action( 'admin_enqueue_scripts', 'my_enqueue_music_features');
The only thing I added was basically this:
'post_type' => 'music'
. Change “music” to your custom post type.
Related Posts:
- Remove slug from custom post type post URLs
- Automaticly add slug to posts
- Custom Post Slug same as Parents Category Slug
- How to controll the Posts post type and general wondering about WP data structure
- Problem to get the link of the default ‘post’ post type like the orther custom types
- List custom taxonomy specific to one custom post type
- Post image in WordPress not appearing on home page
- How to add a custom-post-type post within another custom-post-type post edit screen using AJAX?
- Meta query for custom post type ignored in main query
- Changing custom type name hides the posts
- Child post with numeric only slug keeps redirecting to parent
- Display Ad on Specific Categories
- How to add a post slug to a url?
- Hiding posts by other users and non-logged in
- Adding Post id to the end of slug in a Custom Post Type
- Update Post Meta for a logged in user
- Remove the parent slug in a CPT URL
- Permalink for a custom post type isn’t working and I don’t know why
- Add custom field to Posts and sort by it
- Add custom post type settings to wordress default posts
- How to target a specific custom post type post and its all children and grandchildren?
- Custom rewrite url category
- Get related posts of child term of custom post type
- Two Custom Post Types Many to Many Relationship
- Problem with displaying posts in the CPT category
- Index page with the same id as the slug
- JS innerhtml changing style when using AJAX
- Show titles, date of all posts on single category page
- How can I make the slug of the taxonomy also the slug of the custom post
- Assign same parrent Page to pages AND custom post types
- Allow duplicate slugs for custom post type with taxonomies
- Side effects of Script and Iframe in post
- Nested Custom Post Type or Custom Post Type Parents?
- Programmatically rewriting slug through functions.php but returns 404
- How to change the post type a theme shows by default?
- Create a custom php page and load it at a specific slug
- Custom Post Type with Same Page URL
- Set a checkmark in a category based on a URL-parameter
- Several post types on WP Query by tag and taxonomy
- No Permission to add new Page, Post or CPT with Admin role
- Update postmeta Parent when post_status child change
- custom post type category count shortcode
- Portfolio Page for Classic Posts
- Add post location with mile radius allowing search
- Get the category from custom post type
- Is it possible to store Custom Post Type data in separate set of tables and still have wp_post class functionality?
- Set up post page like JAMA articles
- How to prevent a CPT’s slug and page slug from conflicting with each other?
- Shortcode not working with post counter
- Changing default ‘posts’ parameters with register_post_type_args
- Multiple (two) category postings on the same page.
- Admin Column does not populate with data
- How to integrate a form (Ninja Form or Contact Form 7) with Custom Post Types?
- Removed custom post type slug but not working for child pages
- Prioritize posts in query by meta keys?
- Homepage’s content is dependent on the custom field values (set automatically), how do I get homepage to update without manually updating page?
- Including taxonomy term before post type breaks top level pages
- Allow users to create posts without logging in?
- How to get all tags of a custom post type by id
- How to define which register_post_status goes to which register_post_type?
- Load Next Posts With AJAX not working with custom post type
- Limit the post for differents custom post type in the same wp_query
- Can slugs from posts and custom post types conflict?
- 2 Different Custom Post Types in Submenu
- How to assign classes to all elements?
- Custom Post Type – Duplicate Page Slugs
- How can I show 1 featured post in a styled element, and the next few below differently styled
- Some posts from custom post type to subdomains
- How can i create an custom post template for an specific post category? [closed]
- How to sort posts in a custom post type by title in ascending order by default?
- Redirect to another page using contact form 7? [closed]
- WP the_posts() on single-cars.php get category link
- Conditional for a Single Post That Belongs to a Category?
- $post not working working in AJAX plugin with custom post type
- Remove permalink for custom post type
- Permalink misbehaving in Custom Post Types
- Check post on publish for blank title
- Auto Slug Generation for Custom Post type
- how to check if custom post title exists or not?
- Different Limit number of post on different archive page
- How to change “post_class()” for a custom post type?
- How to make a posttype show under a page hierarchy (example.com/page/posttype/entry)?
- Modify previous and next post links to current Authors Other posts
- Reworking function for counting custom post type posts count
- Create new custom post and post category of same name
- Custom Post Type archive-{post-type}.php not working
- Custom post type single page (single-{CPT-name}) 404 when slug includes hyphens
- wordpress remove views from action links in a custom post
- How do you create %post_type%/%postname%/ permalink structure?
- Load Next WordPress Posts With AJAX?
- Help With Warning on creating new Post types?
- help
- Including link to custom post type in ‘wp_list_pages’ function
- Slug for custom post type
- Rename a slug label
- Get an array wich contains the post_name of every post that has the custom post_type “pelicula”
- Is it a good idea to add a column to the posts table?
- Slug Confusion Between Post and Custom Post types?
- How to find a specific post_type using its “rewrite slug”?
- wp_insert_post wrong post type [closed]