Using Conditional Statements in WordPress Page
-
I am trying to add if else statements to my website to display content based on what month it is. I will start that I have been using HTML in Dreamweaver for years but never used WordPress, so I am not sure of it’s capabilities. I am not even sure that I can use functions in WordPress pages. This is what I am trying to do, and if anyone knows where to point me please let me know.
I am trying to get the month from get the date
<?php
$month = get_the_date(‘m’);
?>
I then try to display content based on that month
if ($month == ‘1’) {
This is January;
} elseif ($month == ‘2’) {
This is February;
} …
Again I am real new, I have been looking all over the knowledge base and it never really say’s if I can do this on a page or is it strictly used in templates.
I have a test site that I am using for now https://bdf.9e6.myftpupload.com you can scroll to the bottom and see some of my non working code.
- The topic ‘Using Conditional Statements in WordPress Page’ is closed to new replies.