• I have created a page that I would like to use as my first page which has a full screen background video (under header and footer)

    https://www.cncf.ie/index (ideally this would be https://www.cncf.ie)

    When a user clicks logo or home on navigation menu they should go to https://www.cncf.ie which is currently my front page https://www.cncf.ie (ideally this would then be https://www.cncf.ie/home)

    My problem is that this page https://www.cncf.ie is currently my front page. (which dissolving slider images and 3 circles)

    Is is possible to have a page BEFORE the front page?

    Or am I missing an obvious solution here?

    My site is password protected as it won’t go live until completed.

    to view use PASSWORD: ireland2013

    I hope my question is comprehensible ?

    This is my first site built using WordPress

    Any help/advice appreciated.

Viewing 15 replies - 1 through 15 (of 30 total)
  • Put the video layout page at /intro
    Place a conditional on first page to check referrer. If referrer is your own website, load first page (the circles). If not, redirect to /intro

    I hope I understood what you want. If you want specific code on how to do it, I can do it for you, but you seem an able coder.

    Thread Starter gerryleonard

    (@gerryleonard)

    Thanks but I think you’ve over estimated my coding chops!

    Did you visit my site? I would like to move my https://www.cncf.ie/index ( currently “sunset” in dropdown navigation “get involved”) so that that is the “first page” (cncf.ie) and my current front page would become https://www.cncf.ie/home. (dont have to be those permalinks but ideally they would be)

    Thanks for your reply but I dont quite follow what u mean or how to go about this without damaging my site.

    So yes if can give me the code that would be great!

    G

    Thread Starter gerryleonard

    (@gerryleonard)

    PS ~ i would also like to make it so that visitors only get the video page if on a desktop as it displays poorly on tablets and isnt well supported on mobiles. (so media queries redirect to “front page/first page” i.e. slider, circles)

    Maybe there is a way to do it the way you want, but here’s my suggesstion:

    1. Put your video-background layout at https://cncf.ie/get-involved
    2. Add this function in your child theme’s functions.php (if you add it in Customizr’s functions.php you’ll lose it on theme upgrade. Please read about how to make a child theme on Customizr’s FAQ list if you don’t know how to do it.):

    add_action( 'init', 'cncf_ie_redirect' );
    function cncf_ie_redirect() {
    	$request = $_SERVER["REQUEST_URI"];
    	$referer = wp_get_referer();
    	if (($request == '/') && ( (!$referer) || ($referer && (strpos(get_site_url(), $referer) !== false)))) {
    		wp_safe_redirect( get_site_url()."/get-involved");
    	}
    }

    How it works: your homepage (https://cncf.ie) is the circles layout. However, anyone trying to reach it, if they come from outside the website, will get redirected to https://cncf.ie/get-involved, where your video-background layout should be. If someone comes from outside to any another page of your website (other than the website URL), they will not be redirected. The redirect is in place only for first page and only if you’re coming from outside the website. (Should behave the same with or without www in your links).

    Does this solve your problem?

    Thread Starter gerryleonard

    (@gerryleonard)

    Thanks Ill try this but change https://cncf.ie/get-involved to https://cncf.ie/intro (which i assume wont be an issue)

    If time would love if you could explain the code snippet (although I should really study the codex myself)

    I have a child theme created already.

    Ill let you know if this works when completed.

    PS
    Any idea on how best to solve the PS question above re media queries determining whether or not visitor get redirected to video intro page?

    thx

    My advice is not to change the redirect based on the device, but rather find a solution to compensate the lack of autoplay on mobile devices (use a background image fallback). You’re going to need this fix anyway, since your /intro is available through menu for mobile devices too, right? Unless you hide it for them, as well.

    However, if that’s your chosen solution replace the if above with:

    if ((!wp_is_mobile()) && ($request == '/') && ( (!$referer) || ($referer && (strpos(get_site_url(), $referer) !== false)))) {
    		wp_safe_redirect( get_site_url()."/get-involved");
    	}

    Thread Starter gerryleonard

    (@gerryleonard)

    I had already put a background image for video (as recommended by plugin author with text that reads “video background if browser support”)

    I will be removing the link in menu to video (sunset) once I have applied your solution as it should not be accessible through menu.

    Thanks for help, hope you like my site? (content to be edited once received from client)

    Thread Starter gerryleonard

    (@gerryleonard)

    sorry what does if (($request == '/') mean exactly ? is that the syntax i use or do i need to add something to this=='/'

    It checks if the user requested the homepage, since $request is $_SERVER[“REQUEST_URI”]. Should have put triple equal there, but it will work regardless. I tested the code on my website after I wrote it and it worked fine. Are you having trouble with it?

    Thread Starter gerryleonard

    (@gerryleonard)

    i have added your code to functions.php (in child theme) and disabled my password protection and discourage search engines to index site.

    BUT when i google search the site and clink on the link (which is https://www.cncf.ie) I get that page rathar than being redirected to https://www.cncf.ie/intro (the video bg page)

    If chance appreciate your help (i cant leave the site live and indexed for long as it is not ready yet)

    Try

    ($request === '') // instead of ($request == '/')

    … but maybe you should make some tests and see why conditions aren’t met.
    Here’s how to test:
    From customizr options select static page as a front page. In that static page, at the start of content put this shortcode: [tester-function]

    And add this function in your functions php:

    add_shortcode('tester-function', 'tester_function');
    function tester_function() {
    	if (current_user_can('update_core')) {
    		$referer = wp_get_referer();
    		echo '$'.'referer = '.var_dump($referer);
    		$request = $_SERVER["REQUEST_URI"];
    		echo '<br />$'.'request = '.var_dump($request);
    		echo '<br />get_site_url() = '.get_site_url();
    		}
    	}

    This should output $referer, $request and the output of get_site_url() for you at the start of home page (under the circles), and you should be able to realize why conditions aren’t met.

    Here’s the if explained: if ((not mobile) and (user requested homepage) and (no $referer or ($referer and $referer contains get_site_url())).

    Thread Starter gerryleonard

    (@gerryleonard)

    changed that line of code ($request === '') // instead of ($request == '/') but didnt resolve issue.

    I am wondering is the issue related to meta data front page? As in when i search for the site in google i find https://www.cncf.ie which when i click brings me to that page and doesnt redirect me to https://www.cncf.ie/intro ?

    Thanks for your help… I am struggling with this.

    Never ran a test before, I will try it but tbh not sure if i would understand the output in order to fix any conditions that arent met.

    Don’t worry, you’ll be the only one seeing the results of the test, since it’s wrapped in

    if (current_user_can('update_core')) {
    // do stuff
    }

    I personally think it’s related to the fact that you run on www and I tested it in clean https:// mode. However, for all I know it shouldn’t matter, but perhaps I’m wrong.

    Thread Starter gerryleonard

    (@gerryleonard)

    Hmmm how can i change it to clean https:// mode?

    Perhaps that would be simplest solution.

    (excuse my tech ignorance)

    Thread Starter gerryleonard

    (@gerryleonard)

    actually mine is https://cncf.ie/ so it is clean https:// mode?

Viewing 15 replies - 1 through 15 (of 30 total)
  • The topic ‘front page versus home page versus index page’ is closed to new replies.