Skip to content
  • Recent
  • Tags
  • Popular
  • Users
  • Search
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse

Lay Theme Forum

  1. Home
  2. General Discussion
  3. dynamically changing site title

dynamically changing site title

Scheduled Pinned Locked Moved General Discussion
3 Posts 2 Posters 99 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Monamos
    wrote on last edited by
    #1

    Hi folks. I would like to make my site title dynamically change, using a set of random words. Has anyone done this or know a way using Lay? I imagine it needs some jquery?

    Let's say the title is "MY WEBSITE". I want it to randomly change from time to time, to use other words. So it can become "MY LIFE", "GREAT WEBSITE", "MY WORLD", etc etc.

    Any thoughts would be greatly appreciated it.

    1 Reply Last reply
    0
    • arminunruhA Offline
      arminunruhA Offline
      arminunruh
      Global Moderator
      wrote on last edited by arminunruh
      #2
      <script>
      /* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random */
      function getRandomInt(min, max) {
        min = Math.ceil(min);
        max = Math.floor(max);
        return Math.floor(Math.random() * (max - min) + min); // The maximum is exclusive and the minimum is inclusive
      }
      var mywords = ['hello', 'hi', 'hallo', 'gutentag', 'salut'];
      setInterval(function(){
          var i = getRandomInt(0, mywords.length);
      var word = mywords[i];
      jQuery('.sitetitle-txt-inner span').text(word);
      }, 3000)
      </script>
      

      best to learn some programming! :)

      M 1 Reply Last reply
      0
      • arminunruhA arminunruh
        <script>
        /* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random */
        function getRandomInt(min, max) {
          min = Math.ceil(min);
          max = Math.floor(max);
          return Math.floor(Math.random() * (max - min) + min); // The maximum is exclusive and the minimum is inclusive
        }
        var mywords = ['hello', 'hi', 'hallo', 'gutentag', 'salut'];
        setInterval(function(){
            var i = getRandomInt(0, mywords.length);
        var word = mywords[i];
        jQuery('.sitetitle-txt-inner span').text(word);
        }, 3000)
        </script>
        

        best to learn some programming! :)

        M Offline
        M Offline
        Monamos
        wrote on last edited by Monamos
        #3

        Thanks @arminunruh you're a star. That literally did exactly what I needed, it just doesn't work on mobile though I think it needs the mobile title class? I tried doing this below but no luck:

        jQuery('.sitetitle-txt-inner span' , '.mobile-title text is-fixed').text(word);
        

        I've tried learning some programming over the years, but CSS is as far as it goes, and the good old "copy/paste/tweak until it works" approach. Appreciate your generous help.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        I also code custom websites or custom Lay features.
        šŸ’æ Email me here: šŸ’æ
        info@laytheme.com

        Before you post:
        1. When using a WordPress Cache plugin, disable it or clear your cache.
        2. Update Lay Theme and all Lay Theme Addons
        3. Disable all Plugins
        4. Go to Lay Options → Custom CSS & HTML, click "Turn Off All Custom Code", click "Save Changes"

        This often solves issues you might run into

        When you post:
        1. Post a link to where the problem is
        2. Does the problem happen on Chrome, Firefox, Safari or iPhone or Android?
        3. If the problem is difficult to explain, post screenshots / link to a video to explain it
        Online Users
        A
        alasdair17
        M
        MATTOFIRE
        Forgot your key, lost your files, need a previous Lay Theme or Addon version? Go to www.laykeymanager.com
        laytheme.com
        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Recent
        • Tags
        • Popular
        • Users
        • Search