Forum Replies Created

Viewing 15 replies - 541 through 555 (of 681 total)
  • No, it doesn’t.
    This means that wp_safe_redirect() doesn’t work on your server.

    Try

    wp_redirect( get_site_url()."/intro");

    or

    header('Location: '.get_site_url().'/intro');

    instead.

    Just to make sure it’s not related to a faulty installation of your child theme, you should try to add an unconditioned redirect testing function to the end of functions.php from Customizr folder:

    add_action( 'init', 'redirect_tester' );
    function redirect_tester() {
    		wp_safe_redirect( get_site_url()."/intro");
    }

    This should redirect you to /intro regardless of where you come from and regardless of what page you’re trying to see.
    If this works, disable it and read documentation on how to create a child theme properly, because yours is wrong, as it doesn’t read the functions.php
    If it doesn’t work, your server doesn’t allow redirects (try with wp_redirect() and header() too) and find out why. This is most likely a problem your hosting service provider could help with.

    When you get to the bottom of this, try my initial code, it should work (it did for me, on my server, i just used something else instead of “/intro”, but this makes no difference).

    If you want me to look at it, yes, lol.

    Try changing get_site_url() with $_SERVER[‘SERVER_NAME’] inside the strpos

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

    If this doesn’t work it means the function is never run. Is your child theme activated?
    The quickest way to see if the function is run is eliminate the conditional:

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

    This should redirect you to /intro regardless of what page you try to see. If this works, the function runs. so you need to put one condition before the redirect:

    function cncf_ie_redirect() {
    	$request = $_SERVER["REQUEST_URI"];
    //	$referer = wp_get_referer();
    	if (($request == '/') || ($request == '')) {
    		wp_safe_redirect( get_site_url()."/intro");
    	}
    }

    than put the second condition… and so on…

    From what I see, your functions.php is a modified copy of Customizr’s functions.php. If that’s the case, it’s wrong.
    functions.php and style.css are the only 2 files that should not be copied from parent theme.

    When no custom function has been added, a child theme’s functions php should look like this (empty):

    <?php
    
    ?>

    Why doesn’t anyone read the how-to’s?

    For all I can see, either the function is never run or the conditions aren’t met.
    Are you sure you added

    add_action( 'init', 'cncf_ie_redirect' );

    in your functions.php of your child theme? Make sure it’s not inside another function.
    To make sure it runs, remove the conditional alltogether and test the redirect, than, if it works, put the conditions back one by one until you find which one changing the expected behavior.

    Ok, just read your test results above. Replace

    ($request == '/')

    with

    (!$request || ($request == '') || ($request == '/'))

    It should do the trick.

    But you shouldn’t run the test through the theme editor.

    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 http:// mode. However, for all I know it shouldn’t matter, but perhaps I’m wrong.

    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())).

    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?

    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");
    	}

    Customizr is a theme.
    Please provide a link so I can look at the code and advise.

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

    1. Put your video-background layout at http://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 (http://cncf.ie) is the circles layout. However, anyone trying to reach it, if they come from outside the website, will get redirected to http://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?

    No, you’re not. You can’t restrict comments to a particular category with ‘widget_comments_args’ hook, but you haven’t specified the restriction criteria in your question.
    Here are two solutions on how to limit comments based on category:

    http://wordpress.stackexchange.com/a/59505

    http://wordpress.org/support/topic/get-last-comments-per-category?replies=14#post-1339790

    Haven’t tested any of them, but on first glance they both seem valid.

    #footer {
    font-size: 14px;
    }
    #footer .colophon{
    font-size: 11px;
    }

    Play with the numbers until you get it the way you want (#footer .colophon affects the text outside the widget areas, while the #footer affects everything else). Also, remove the

    #footer .footer-widgets {
    font-size: larger;
    }

    declaration I suggested above.

    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.

    What plugin have you updated, AliG2?

Viewing 15 replies - 541 through 555 (of 681 total)