Welcome To Snipplr
Everyone's Recent PHP Snippets
- All /
- JavaScript /
- HTML /
- PHP /
- CSS /
- Ruby /
- Objective C
This is a great way to save complex objects as cookie values. You can't just json_encode because commas are not legal in cookie values. Remember not to use this for anything too big because cookies have a 4KB limit.
1
716
posted 15 years ago by segdeha
Adds two "sidebars" to the header. You can drag and drop widgets into them just like any other sidebar from your WP dashboard. You can change the Hook to move the "sidebars" somewhere else on the page. For example, change 'thesis_hook_header' to '...
4
1851
posted 15 years ago by fouroclockproject
Completely changed original function, which stopped working around WP2.8.
1
808
posted 15 years ago by kristarella
There's another snippet on here that always comes up on google for finding the relative path to the root, but it doesn't work very well. This version will work from the root, from any subdirectory, and with malformed path names such as www.example.co...
3
1210
posted 15 years ago by blackhole12
This little bit of code is a calculator of the "golden mean" of a given length of time. For example: given a length of 1 minute and 0 seconds, the answer given will be 0:00:37. See U2's "With or Without You", the Greek Parthenon, the human body, etc....
1
1073
posted 15 years ago by rossuber
All you need to do when writing the post, is enter a custom field with the key "expiration" and set the value in the format: "2010/01/01 18:20:00" - this would expire the post at 6.20pm on the 1st January 2010.
1
746
posted 15 years ago by gjindancer
I pieced together this code when I had to do this for a client:
- show the first image attached to a post (based on sort order in gallery tab) in medium size
- put all the other images attached to the post into an imageset so that when you click on...
1
1025
posted 15 years ago by zartgesotten
This will output the resulting meta value (notice the addition of "echo"):
1
758
posted 15 years ago by rickfu