Adding a custom field to a slug

Try to use function sanitize_title() – documentation, which converts a string into a slug when you check if it is already in the permalink, and when appending it to permalink: function custom_job_post_type_link( $post_id, $post ) { $permalink = $post->post_name; $companyname = $post->_company_name; if ( strpos( $permalink, sanitize_title($companyname) ) ) { // <– Here return; } … Read more