Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #653550

    hi guys,

    any idea how i can get this function to work?

    many thanks!

    #653585

    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

    #653625

    Hi there,

    added the function to functions.php – doesn’t seem to be working. Any other suggestions?

    #654124

    any update on this?

    thanks

    #654547

    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

    #654563

    Nice job! Thanks. You can close this thread.

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘function not working – change page title’ is closed to new replies.