Hello,
We found that WordPress default function strips %ca from the string on sanitize. There is already ticket open at WordPress forum. See https://core.trac.wordpress.org/ticket/31777
For now use following PHP snippet to prevent this issue. Try to resave CPT with %%category%% again.
/**
* sanitize_text_field() stripping instances "%ca" from %%category%%.
*
* See https://core.trac.wordpress.org/ticket/31777
*/
function gd_snippet_20190827_save_post_type( $output, $post_type, $raw ) {
if ( ! empty( $output[ $post_type ]['description'] ) ) {
$output[ $post_type ]['description'] = gd_snippet_20190827_fix_strip_ca( $output[ $post_type ]['description'] );
}
if ( ! empty( $output[ $post_type ]['seo']['title'] ) ) {
$output[ $post_type ]['seo']['title'] = gd_snippet_20190827_fix_strip_ca( $output[ $post_type ]['seo']['title'] );
}
if ( ! empty( $output[ $post_type ]['seo']['meta_title'] ) ) {
$output[ $post_type ]['seo']['meta_title'] = gd_snippet_20190827_fix_strip_ca( $output[ $post_type ]['seo']['meta_title'] );
}
if ( ! empty( $output[ $post_type ]['seo']['meta_description'] ) ) {
$output[ $post_type ]['seo']['meta_description'] = gd_snippet_20190827_fix_strip_ca( $output[ $post_type ]['seo']['meta_description'] );
}
return $output;
}
add_filter( 'geodir_save_post_type', 'gd_snippet_20190827_save_post_type', 0, 3 );
function gd_snippet_20190827_fix_strip_ca( $text ) {
if ( ! empty( $text ) ) {
$text = str_replace( "%tegory", "%%category", $text );
}
return $text;
}
Thanks,
Kiran