Adding conditional statement
-
I am creating a theme and I need my index.php to behave in the following manner:
>> If you are on the home or front page the file: slideshow.php is used.
>> If it is not the home or front page, the file: archive.php is used.Basically, I would like the user to be able to designate a “posts” page in the settings (in this case, I chose a page named “blog”) without having to designate a home page, so that they may use the home page template w/o having to create a page and assign a home page template. I would like this to happen automatically. The only thing they will need to do is assign a “posts” page.
Here is the code I came up with on the index.php page. It behaves as I wish for the homepage, but I cannot get my desired results for the “blog” page. Currently this code is producing the slideshow.php template on both the home page and the “blog” page that I have selected.
<?php if ( is_home() || is_front_page()) { include (‘slideshow.php’); }
elseif ( is_page()) { include (‘archive.php’); }?>
Please let me know if you need more explanation.
The topic ‘Adding conditional statement’ is closed to new replies.