| | #1 |
| Warrior Member War Room Member Join Date: 2013
Posts: 8
Thanks: 6
Thanked 0 Times in 0 Posts
|
I used to have the below script imbedded on my sales page so that the date and time would change everyday at midnight. But when I change to wordpress the script wont function anymore. I have been manually changing the date everyday for the past two years but its starting to get to be a pain in the butt. I've procrastinated long enough and need to get this script compatible for wordpress What kind of script do I need to work in wordpress and where can I get someone to make one. I'm guessing to only take about 5 minutes to write it out. <script> var mydate=new Date() var year=mydate.getYear() if (year < 1000) year+=1900 var month=mydate.getMonth() var daym=mydate.getDate() if (daym<10) daym="0"+daym var montharray=new Array("January","February","March","April","May"," June","July", "August","September","October","November","Decembe r") document.write(""+montharray[month]+" "+daym+"") </script> Thanks |
| |
| | #2 |
| Advanced Warrior War Room Member Join Date: 2006 Location: USA
Posts: 1,907
Thanks: 236
Thanked 1,377 Times in 676 Posts
|
Good grief... that's a lot of code just to display the current date! You can do the same thing with just 1 line of PHP... PHP Code: |
| | |
| |
| | #3 | |
| Web Developer War Room Member Join Date: 2012 Location: Vancouver, BC
Posts: 593
Thanks: 149
Thanked 162 Times in 133 Posts
|
The best way to do it is as Brandon has showed. As a side note, this is how websites display the current year for copyright: PHP Code: | |
| ||
| |
| | #4 |
| Warrior Member War Room Member Join Date: 2013
Posts: 8
Thanks: 6
Thanked 0 Times in 0 Posts
|
that is the format I want however JS does not work in my wordpress I put in Brandon script it it did the same thing as my script which was nothing. Nothing shows up. I need some other type of language that works in wordpress.
|
| |
| | #5 |
| Advanced Warrior War Room Member Join Date: 2006 Location: USA
Posts: 1,907
Thanks: 236
Thanked 1,377 Times in 676 Posts
|
lol. WordPress is built on PHP! If you don't know how to insert PHP code into WordPress pages, then maybe this will help... WordPress › Allow PHP in Posts and Pages « WordPress Plugins And just for the record, Javascript works in WordPress too... http://codex.wordpress.org/Using_Javascript |
| | |
| |
| | #6 |
| Warrior Member War Room Member Join Date: 2013
Posts: 8
Thanks: 6
Thanked 0 Times in 0 Posts
|
Hi again Brandon. Ok I guess I'm doing something wrong. I'm taking the script you gave me, going on the page I want to edit and then clicking the html tab. I then paste that script and hit update. But then when I view the page in the browser there's no date. I looked at that plug in but it does away with html and I'd have to go over to BBcode. I know hot to write html and I don't want to redo the whole page in BBcode. Not to mention I don't like using plug-ins for minor things like this. Since wp is written in php why cant I just insert the script you gave me into the page and it work? lol What do I need to do? This is basically why I have procrastinated doing this for 2 years because I knew it was going to be some pain in the ass thing that took me hours and hours of time to for just one little thing. I've been sitting here for 3 days 24 hours a day trying to figure this out reading and reading, trying things and I can't get it. I've spent more time over the last 3 days then when I add up the 2 minutes a day for the last 2 years to change it manually at 12am everyday. 2 minutes a day everyday for the last 2 years works out to a total of 24.3 hours total time. I have already tripled that time trying to figure out a way to have it done automatically. |
| |
| | #7 |
| Active Warrior War Room Member Join Date: 2009 Location: NSW, Australia
Posts: 60
Thanks: 0
Thanked 9 Times in 9 Posts
|
Normally in WP the line of PHP code would go in the template for the page, post or whatever you are working on. . Where are you placing it? Putting that code in the post edit box results in it being commented out, which is why you see nothing. So you need to find a way around that. If you don't like the plugin suggested by Brandon have a look at this one WordPress › PHP Code for posts « WordPress Plugins |
| |
| | #8 |
| Active Warrior War Room Member Join Date: 2012 Location: Tennessee
Posts: 38
Thanks: 0
Thanked 3 Times in 3 Posts
|
As stated, it all depends upon where you are putting it. For example, if you are putting it in a footer, you could make a child theme, copy over footer.php into your child theme, and then add the PHP code to the footer.php in the child theme.
|
| How to Drive Traffic To Your Website Free + Paid Reports & Training Courses SEOalaCarte.com ******************** Cheers, Jonathan Sherman | |
| |
| | #9 | |
| Web Developer War Room Member Join Date: 2012 Location: Vancouver, BC
Posts: 593
Thanks: 149
Thanked 162 Times in 133 Posts
|
| |
| ||
| |
| | #10 | |
| Warrior Member War Room Member Join Date: 2013
Posts: 8
Thanks: 6
Thanked 0 Times in 0 Posts
|
"You arrived at this page in time for my special offer. Through March 14th 2013 I've lowered the price to $27. If you sign up after this date blah blah blah..." "Sign up now for just $47 ($27 thru March 14th 2013)" etc etc | |
| |
|
| Bookmarks |
| Tags |
| auto, change, month, or date, script |
| |