Keep Title and Description always

In any properly coded theme the title should be completely generated with wp_title() and easily filterable to specific string (in functions.php or otherwise): add_filter( ‘wp_title’, function () { return get_bloginfo( ‘name’ ) . ‘ | ‘ . get_bloginfo( ‘description’ ); } );

Replace text in the Title

First things first, lets clean up your code: <?php $wptitle = the_title(); $wptitle = str_replace(‘&’, ‘and’, $wptitle);?><?php echo $wptitle; ?> Lets remove the PHP tag spam and put things in nice clean lines: <?php $wptitle = the_title(); $wptitle = str_replace(‘&’, ‘and’, $wptitle); echo $wptitle; ?> Now if we look at the problem, the_title, that function … Read more

Cannot use ‘CSS’ in post title

Disable all plugins. One of them puts all words with capital letters in a <span class=”caps”> container. In <meta property=”og:title” content=”test <span class=”caps”>CSS</span> title” /> … this closes the <head> section automatically because output is not allowed in <head>. If you have found the plugin tell its author about the Bug. I’m sure s/he wants to … Read more

Split the_title

The best way to go about it is using the the_title filter. Put the following code in your functions.php. add_filter( ‘the_title’, ‘wpse_64467_prefix_title’, ”, 2 ); function wpse_64467_prefix_title( $title, $id ){ $header_title = get_post_meta( $id, ‘header_title’, true ); $title = ( $header_title ) ? $header_title . ‘ – ‘ . $title : $title; return $title; } … Read more

How to override the title tag for woocommerce endpoints?

If you added custom WC endpoints on init, you can use something like this instead to check for endpoints (adjust accordingly if you’re using Yoast): function add_custom_endpoints_to_title( $post_title ) { if ( ! is_account_page() ) { return $post_title; } global $wp; if ( isset( $wp->query_vars[‘custom_endpoint_1’] ) ) { $post_title=”Custom Endpoint 1″; } elseif ( isset( … Read more