![]() |
![]() Code Stuff |
I've been designing websites since 1995, but had never strayed further than HTML, CSS, and drop-in scripting add-ons that I could usually fiddle with to fit my needs. In 2006, one of my websites was falling apart under the load of hundreds of posts. It was time to find a new blogging engine and luckily I found WordPress. It worked well for us for awhile but eventually we were ready to take our website to the next level—which meant straying from simple templates. With the right knowledge you can do just about whatever you want with WordPress. So recently I set out to learn PHP and JavaScript and it has really changed the way I create pages now. The past 15 years almost seem wasted in that I should have learned this earlier! I'm a pretty good autodidact when it comes to computer stuff, and relied heavily on books and websites to teach me what I needed. Luckily there are a lot of people out there willing to help out beginners and share what they know. Now I feel I'm at a point where I can give a little bit back. I don't have the time to check out support forums and I can't really give out email advice. But I can post some things here that might help out other web developers trying to solve issues they have that I went through.
Please note that I am admittedly new to all this, having been doing WordPress editing for just a few years and PHP and JavaScript less than that. So I'm not going to pretend there aren't better, cleaner, or more efficient ways to do some of these things out there. All I can tell you is what I've done on my sites. Also, as I mentioned above, a lot of what I have learned came from others. There are a lot of sites out there where you can find out how to do things. I'm not going to just copy and paste interesting stuff from there to here. The following is code I either created or adapted from others to serve a specific purpose on one of my sites that might also be useful to others.
COPYRIGHT YEAR UPDATES
(PHP): Keep your website's copyright notice updated without any work.
SIMPLE RANDOM IMAGE
(PHP or JAVASCRIPT): If you want to insert a random image into a page but want to do it with a minimum about of code, here is a very simple way to do it.
CATCH DROP DOWN DUPLICATES
(JAVASCRIPT): Warn users if they have picked the same value among many drop down menu items that must all be different.
TODAY'S DATE FORM
(JAVASCRIPT): Sometimes when you want a user to enter a date into a form it is best to have the form default to the current day. With JavaScript this is not only easy, but it can also speed up the HTML coding of the form itself.
POST EXPIRE
(WORDPRESS): If you run a WordPress installation with two loops, one of which is a "featured" loop that shows the most recent post in a certain category, POST-EXPIRE will show you how to make that section disappear and have its post move to your other loop after a certain number of days.
POST LITE
(WORDPRESS): If you run a WordPress installation with two loops, one of which is a "featured" loop that shows the most recent post in a certain category and the other a loop that shows the rest of your content, POST-LITE will show you how to selectively make certain featured posts appear in the top loop but then not move to the bottom loop when a new featured post goes up.
SMART BACK TO LAST PAGE
(WORDPRESS): Create a back button that only appears in a certain category and doesn't send readers off your site.