hi guys,
any idea how i can get this function to work?
many thanks!
Hi clairemartindigital!
You can add the following to your functions.php file
function add_custom_script() {
?>
<script>
$(function() {
// Get page title
var pageTitle = $("title").text();
// Change page title on blur
$(window).blur(function() {
$("title").text("Don't forget to read this...");
});
// Change page title back on focus
$(window).focus(function() {
$("title").text(pageTitle);
});
});
</script>
<?php
}
add_action('wp_head', 'add_custom_script');
Please do let us know if we can do anything else from you.
Regards,
Basilis
Hi there,
added the function to functions.php – doesn’t seem to be working. Any other suggestions?
any update on this?
thanks
Hi,
Please try adding the code to functions.php file as following
function custom_title_code(){
?>
<script>
jQuery(window).load(function(){
// Get page title
var pageTitle = jQuery("title").text();
// Change page title on blur
jQuery(window).blur(function() {
jQuery("title").text("Don't forget to read this...");
});
// Change page title back on focus
jQuery(window).focus(function() {
jQuery("title").text(pageTitle);
});
});
</script>
<?php
}
add_action('wp_footer', 'custom_title_code');
Best regards,
Yigit
Nice job! Thanks. You can close this thread.