• Resolved mrcangrejero

    (@mrcangrejero)


    To display a message only if I’m in a spacific site, I’ve used this:

    <?php
    $current_site = get_current_site();
    If $current_site == "NotisegurosPR";
    	"Favor de notificar errores a <a mailto:[email protected]>NotiSegurosPR</a>";
    ?>

    Doesn’t work. I can’t find a solution. Any help appreciated. Thanks!

Viewing 11 replies - 1 through 11 (of 11 total)
  • Can you clearify more on this? Are you trying to check the language of the current site or what? Is the site multi lagugage? Please explain.

    Thread Starter mrcangrejero

    (@mrcangrejero)

    Thanks, WEN Solutions.

    The issue is the following. My WordPress installation at GoDaddy is configured for multisites and is the English version. In Setings ==> General for sites 1 and 2, the language is set for English(United States). In site 3, Setings ==> General is set for Spanish (Espa?ol).

    All sites use a Child Theme with its own modified footer.php. I would like to modify that PHP file so that it checks to see if site 3 is the active site. If it is, I want to display something like Notify errors to <a mailto:[email protected]>NotiSegurosPR</a>. Otherwise, don’t display the mailto line.

    Hope you can help. Thanks again!

    Hello @mrcangrejero, you can take reference from below codes:

    <?php
    $current_site = get_current_site();
    echo 'You are viewing ' . $current_site->site_name;
    ?>

    First of all just check which site is active currently by using echo 'You are viewing ' . $current_site->site_name;. This will give you a output like ‘You are viewing: spanish_site[suppose].
    Then, just check if($current_site->site_name)=='spanish_site', and inside the if condition write what ever you need. Hence, if user goes to spanish site then that if condition will work & output the elements inside above if condition.
    Thanks!

    Thread Starter mrcangrejero

    (@mrcangrejero)

    WEN Solutions. Thanks for your help.

    I used this:

    <?php
    $current_site = get_current_site();
    // echo 'You are viewing ' . $current_site->site_name;
    	if($current_site->site_name) == 'NotiSegurosPR',
    		"Favor de notificar errores a <a mailto:[email protected]>NotiSegurosPR</a>";
    	else;
    ?>

    Got this message:
    Parse error: syntax error, unexpected T_IS_EQUAL in /home/content/80/12126080/html/wp-content/themes/cang/footer.php on line 38
    Have no idea what does it mean. Any help is appreciated. Thanks!!

    Please use ‘if’ condition taking the below reference:

    if($current_site->site_name == 'NotiSegurosPR')
    {
    "Favor de notificar errores a <a mailto:[email protected]>NotiSegurosPR</a>";
    }

    Seems slight mistake on your code.
    Thanks!

    Thread Starter mrcangrejero

    (@mrcangrejero)

    Thanks again, WEN Solutions!

    Tried your code above, tried it adding <?php ?>, and tried it adding a semi-colon after == 'NotiSegurosPR'), but couldn’t make it work. Hope you can still help. Regardles, wish you and yours the best!

    so What error is seen now? can you post it? Also your codes, please post your codes.

    Thread Starter mrcangrejero

    (@mrcangrejero)

    Thanks, WEN Solutions.

    With the following code …

    <div class="container-fluid">
        <div class="row">
            <div class="col-md-12 text-center">
                if($current_site->site_name == 'NotiSegurosPR')
                {
                "Favor de notificar errores a <a mailto:[email protected]>NotiSegurosPR</a>";
                }
            </div> <!-- /col-md-12 -->
        </row>
    </div> <!-- /container-fluid -->

    … I don’t get an error, but the following is displayed on the site/page …
    if($current_site->site_name == 'NotiSegurosPR') { "Favor de notificar errores a NotiSegurosPR"; }

    Adding <?php ?> to the same code …

    <div class="container-fluid">
        <div class="row">
            <div class="col-md-12 text-center">
                <?php
                if($current_site->site_name == 'NotiSegurosPR')
                {
                "Favor de notificar errores a <a mailto:[email protected]>NotiSegurosPR</a>";
                }
                ?>
            </div> <!-- /col-md-12 -->
        </row>
    </div> <!-- /container-fluid -->

    … I don’t get any error but nothing is displayed, either.
    I’m placing them in my child’s footer.php
    Take care!

    You are not displaying your codes that is inside ‘if’ condition. You have to ‘echo’ your content like this.:

    <?php
                if($current_site->site_name == 'NotiSegurosPR')
                {
                echo "Favor de notificar errores a".'<a href="mailto:[email protected]">NotiSegurosPR</a>';
                }
                ?>

    Thanks!

    Thread Starter mrcangrejero

    (@mrcangrejero)

    Dear WEN Solutions:

    It’s been a long run but, with your suggestions, I learned a lot. When running your code above, I noticed that “$current_site->site_name” doesn’t check for Site Title. Actually, the “if” statement was alway “false” because “$current_site->site_name” produced the site’s url; “https://wp-multisites.com/&#8221;. By chance, I found “site_url”. Made a few changes to your code and, alas it worked. This is what I finally did:
    `<?php
    $url = site_url();
    if($url == ‘https://wp-multisites.com/nspr&#8217;)
    {
    echo “Favor de notificar errores a “.’NotiSegurosPR.’;
    }
    ?>
    You have no idea how much I’ve enjoyed this experience. I wish that everyone here were as patient and forgiving as you were. For that, I will always be grateful. Once again, thanks, and the best to you and yours.

    Great to hear that. If you have any further issues, kindly post it. And please mark this ticket as resolved.
    Thanks!

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Displaying A mailto Link Only On Specific Site’ is closed to new replies.