I have two custom post type. Then I need to use title_save_pre to post title prior to saving it in the database. I need to use this filter just for one custom post type.
This is my function:
<?php
function muda_titulo() {
global $post;
$type = get_post_type($post->ID);
if ($type== 'event') {
$title = $post->post_excerpt;
$day= get_the_time('l, d F, Y');
return $title.' - '.$day;
} else if ($type == 'post') {
// do nothing
}
}
add_filter ('title_save_pre','muda_titulo');
?>
On custom post type ‘event’ it works fine, but on custom post type ‘post’ the title changed to a white space.
Thank u
Try the code below. Filter’s take a value and returns it afterwards.