3

Is there a code condition that I can call to detect if the user is currently on my sites homepage.

In Wordpress (and I'm sure I will get panned for making this comparison) there is an 'is_homepage' conditional that returns true when the homepage is being viewed.

Any tips much appreciated.

5

Generally speaking the home page can be called to ways: (1) in absence of {segment_1} or (2) when the site is using the designated primary template_group and index.

Let's deal the first one first, you'd just use the conditional

{if segment_1 ==""} what you want {/if}

Will test for the home page. Now, if you also consider it the 'homepage' when people are on the designated 'index' page, regardless of if they are at your base domain, then you'd want

{if segment_1=="archive" && segment_2=="index" OR segment_1==""} {/if}

where 'archive' would be whichever template_group you set to hold the primary index page.

You'll want to test the second option, but it should work. You'd want to use the conditional that requires the AND statement before the condition that is the OR.

1
  • Thanks nonprofit_tech - the first option there is doing the trick for me!
    – Tomtids
    Mar 1 '13 at 14:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.