filter the title changed also the page titles

I created a custom post type with different input fields.
For example first name and last name.

So I want this inputs as title in the post column-list.
To do this I used the filter option:

add_filter( ‘the_title’, function( $title ) {
$title_firstname = esc_html( get_post_meta( get_the_ID(), ‘first_name’, true ) );
$last_name = esc_html( get_post_meta( get_the_ID(), ‘last_name’, true ) );

$title = $first_name . ‘ ‘ . $last_name;
return $title;
} );

Okay this works for me but there is one problem:

All titles form default-posts and pages are gone.

Whta can I do to change only my custom post titles?

Hope somebody can help me 🙂

Kind reagrds,

Jop

Read more here:: filter the title changed also the page titles

Leave a Reply

Your email address will not be published. Required fields are marked *