Okay
  Public Ticket #3691100
Video landing pages and logo link URL
Closed

Comments

  • Richard started the conversation

    I have just been trying setting a video landing page as the default page. Works fine, but I don't want this to be the page that visitors keep going back to while navigating the site. 

    I can't work out how to change the link that is attached to the logo that gets added to the menu.

    I am using the "crew" theme. Site is not live yet, and so is protected by password.

  • Richard replied

    I have sussed this out by using a cookie. For anyone else interested, this is what I did:

    Used WPCode plugin for javascript snippets.

    Added a global javascript snippet containing a couple of functions

    function create_cookie(name, value, days) {
        var expires = "";
        if (days) {
            var date = new Date();
            date.setTime( date.getTime() + (days*24*60*60*1000) );
            expires = "; expires=" + date.toGMTString();
        }
        document.cookie = name + "=" + value + expires + "; path=/";
    }
    function get_cookie(name) {
        var nameEQ = name + "=";
        var ca = document.cookie.split(';');
        for (var i = 0; i < ca.length; i++) {
            var c = ca[i];
            while (c.charAt(0) === ' ') {
                c = c.substring(1, c.length);
            }
            if (c.indexOf(nameEQ) === 0) {
                return c.substring(nameEQ.length, c.length);
            }
        }
        return null;
    }

    Then added this javascript snippet to the landing page

    // Create cookie so that the user is no longer redirected
    create_cookie('landing_visited', 'true', 30);
    

    ..which creates a cookie that will last for 30 days.

    ...and this final javascript snippet to the home page

    if ( get_cookie( 'landing_visited' ) == null ) {
        window.location.href = "/landing";
    } else {
        create_cookie('landing_visited', 'true', 30);
    }
    

    ...so if the cookie doesn't exist, they get redirected to the landing page (in my case, the landing page slug was "landing"). If the cookie does exist, then the expiry date will be updated to be 30 days hence.

    ...if you wanted, then you could add this last snippet to all pages on the site.

  •  653
    Alexandre replied

    Thank Richard for sharing your solution.

    Thanks,


    Alexandre from the Sonaar.io Crew