May be it is a unreal question. But i want to know that is there any way to change automatically "-" to "," in wordpress post title?
i.e. :
if someone add a new post with this title = wordpress-example-title
it automatically converts it into = wordpress,example,title
.
I did a thing, i put $title=str_replace('-',',',$title);
in wp-includes/post-template.php
. Now post heading is working well, it is converting hyphens into commas, but the title of the post is still same. I'm using yoast wordpress seo which is force rewriting titles.
First, you should NEVER change the core WordPress files. You should only have to change your theme files for this (usually the functions.php file). There is a filter that you need to use to change the title called wp_title
. You can call it using add_filter( 'wp_title', 'theme_title' );
but since your using YOAST, you need to add priority to it so its executed after YOAST like so add_filter( 'wp_title', 'theme_title', 11 );
Here is an example:
function theme_title( $title ) {
return str_replace('-',',',$title);
}
// This is called after YOAST
add_filter( 'wp_title', 'theme_title', 11 );