Monday 16 October 2017

Wordpress: Change the title of any custom page dynamically

Sometime we want to custom the title for some page eg: 404, contact, search .... It is very simple, follow these instructions.

in file "your_theme/function.php" add the following code at the end.

function setTitle($title) {
    add_filter( 'wp_title', function() use ($title) {return $title;}, 10000 );
}

Done ! From now on, which page should be customized so that you just call the function like this:

setTitle('Hello, this is my custom title');

It does not affect the pages you do not use. Have fun!

1 comment:

  1. Online thecasinosource.com betting received a boost in March 2022 because the state not required in-person registration. There are seven online sportsbooks within the state, together with DraftKings, BetMGM, Caesars, and FanDuel. This online playing market analysis report delivers a complete perspective of every little thing you want, with an in-depth evaluation of the current and future scenarios of the business.

    ReplyDelete