I recently decided to add a bit of fun and personalization to my WordPress website by changing the default page title separator. Instead of the usual dash or pipe, I wanted to use a random emoji as the separator. It’s a small detail but can add a lot of character to the site!
Firstly, I navigated to my WordPress dashboard and accessed the theme editor under Appearance > Theme Editor. From there, I located and opened the functions.php
file of my active theme.
Next, I added a filter function to modify the document title separator. Here’s the snippet of code I used:
add_filter('document_title_separator', 'custom_title_separator');
function custom_title_separator($sep) {
$emojis = array('ðïļ', 'ðĶ', 'ðĶĒ', 'ðĶĐ', 'ðĶ', 'ð', 'ðŠļ', 'ðĶ', 'ð', 'ðģ', 'ð', 'ð·', 'ð', 'âïļ', 'ðļ', 'âš', 'ðĄ', 'ð ', 'ðïļ'); // Array of emojis
$random_index = array_rand($emojis); // Get a random index
$random_emoji = $emojis[$random_index]; // Get the emoji at the random index
return $random_emoji;
}
In this code snippet, I defined an array of emojis that I wanted to use as separators. Each time a page loads on my site, this function selects a random emoji from the array and sets it as the page title separator.
After adding this code snippet, I clicked on the Update File button to save the changes in my functions.php
file.
Now, whenever I navigate through my WordPress site, I see a different emoji as the page title separator, adding a touch of fun to the user experience.
Changing the page title separator to a random emoji was a simple customization that made a noticeable difference on my site. It’s these small tweaks that can really enhance the overall look and feel of your WordPress website!