• Resolved lesnaya

    (@lesnaya)


    Hey guys,

    any idea how to disable “clickability” on the Header only for Home page?
    I need Header on all other pages remain clickable as they lead to Home page, but on Home – to disable this somehow.

    I have this in header.php:

    <div id=”header” onclick=”location.href=’https://sitename.net/&#8217;;” style=”cursor: pointer;”>

Viewing 8 replies - 1 through 8 (of 8 total)
  • Hi Lesnaya.,

    just try this code

    <div id="header" <?php if( ! is_home() ){?> onclick="location.href='https://sitename.net/';" style="cursor: pointer;" <?php }?>>

    Thread Starter lesnaya

    (@lesnaya)

    Hi Rajan, thank you very much for your response and for the tip.

    I did try this line – but didn’t work. (I tried both – with removing my original line and with leaving both of them in – none did trick, unfortunately).

    Hi Lesnaya,

    if is_home() not working then you can use is_front_page() it should work.

    Try this

    <?php
    if( is_front_page() )
    $clickable = ”;
    else
    $clickable = ‘onclick=”location.href=’https://sitename.net/&#8217;;”‘;
    ?>

    <div id=”header” <?php echo $clickable;?> style=”cursor: pointer;”>

    its the same code but different way, just think may be its easy for you.

    Thread Starter lesnaya

    (@lesnaya)

    Hi Innovativeroots, thank you very much for this variant. Where do i put the <?php part? So far where I tried it in the Header.php is gave Syntax error, I assume it goes to a specific location in the document..?

    Thread Starter lesnaya

    (@lesnaya)

    Innovativeroots! Yay, i combined two advices and did this:

    <div id=”header” <?php if( ! is_front_page() ){?> onclick=”location.href=’https://website.net/&#8217;;” style=”cursor: pointer;” <?php }?>>

    And it worked ??
    Sorry if I misunderstood your message, I might have due to pink dresses in the wardrobe..

    THANK YOU THANK YOU!!

    just tried it into my header.php file

    just changed
    this
    $clickable = ‘onclick=”location.href=’https://sitename.net/&#8217;;”‘;
    to
    $clickable = ‘onclick=”location.href=\’https://sitename.net/\’;”‘;

    it will work without any error. if still not worked, please reply so i will check it again.

    you are welcome.

    Thread Starter lesnaya

    (@lesnaya)

    Innovativeroots, thank you again. I will stay with the solution I mentioned above, as it worked, and I usually try not to touch what’s working due to lack of knowledge what to do about it if I mess up…

    Thank you very much in any case, your suggestion totally brought great results.

    Enjoy the day!!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Disable clickable Header on Home page’ is closed to new replies.