How to show users search phrase in SEO Title

Pulling my comment as an answer: Assuming you want your page to interact with the google search, I don’t think that’s possible, at least without “black hat” measures and potentially getting blacklisted by Google. The “current” best practice is to either have a “meat delivery” page that lists your locations or have n amount of … Read more

Replace post title based on conditions

You can use the_title filter to modify the post_title prior to printing on the screen. add_filter(“the_title”, function($title, $id)){ $user = wp_get_current_user(); if((!is_user_logged_in() || in_array(“pending”, $user->roles)) && “post” === get_post_type($id)){ $title = “Custom title”; } return $title; }, 10, 2); source: https://developer.wordpress.org/reference/hooks/the_title/

Safe way to get the post ID in the_title()

Some filters in WordPress are just not user friendly and does not always quite do what one wants to. the_title filter will apply changes to all instances of get_the_title() (which is used by the_title()). So widget titles, related posts titles and post link titles are all changed, which is a problem when you just need … Read more

Get post/page title from ID

If you have only ID of a post and you want only the title of that post, then using get_post_field will be best way to do this, I guess. The syntax of this function: get_post_field( $field, $post_id, $context ); So code, that will solve your problem looks like that: $title = get_post_field( ‘post_title’, $POST_ID ); … Read more

How to split up the_title and insert a span tag

its best if you just use custom field type to create a sub title… That way you leave the title un-touched and just add a field where you can insert a value like so (calling field sub title): Then you can fetch your subtitle easily: <?php $sub_title=get_post_meta($post->ID,’subtitle’,true); if($sub_title != ”) { echo ‘<h1>’. the_title() .'<span>’. … Read more