Hi,
I am creating a website using WordPress as CMS and I want a static front page. This front page has some features I don't want on regular pages and therefor I wonder how I can set up a PHP-query to check if the current page is the front page, and if so place some special code in there.
Thank you in advance.
In your index.php theme file use this
<?php if (is_home()) { do something }?>
to check.
If you have a static front page set as "home", then you need to use
<?php if (is_page('Home')) { do something } ?>
(obviously insert the slug of the page you have set as "home")
In my page.php file (the front page is a page after all) I tried using:
<?php if ( is_home() ) { ?>
html here... tadadum...
<?php } ?>
I also tried this in index.php but neither gave any result.
even if the front page is actually a Page, it is still called from the index.php, I believe.
Try the second code I gave you, since the "is_home" function will not work if your front page is a Page. then you need to ask if the current Page is the Page with the name "home", or whatever you call it.
Thank you. Using that code in the page.php made everything work exactly as I wanted it to.
ktsixit
Member
Posted 3 years ago #
I'm using a static page as a frontpage but non of the two pieces of code you suggest is working.
My frontpage's title is in greek, I don't know if this may be a problem, although I have changed the encoding of index.php file.
Am I missing something?