post title not changing at post page

You have a few ways to do it

if (get_post_type($id) == 'post' || get_post_type($id) == 'page')

If you use the same function more than once its better to create a variable that will hold that value, so like this

$type = get_post_type($id);

if ($type == 'post' || $type == 'page')

You could also do something like this

if (in_array(get_post_type($id), ['post', 'page'])) 

In this situation I would go with the in_array option, no variable created and very clean.

But you can use which ever option you like, the final result will be the same