Welcome To Snipplr


Everyone's Recent PHP Snippets Tagged wordpress



For use within The Loop, in your portfolio item page template.
0 769 posted 15 years ago by tylersticka
Usually use in a template with `in_category()`, like `if ( in_category( 3 ) || in_subcategory( 3 ) ) { ...`. Tested in WP 2.8.4.
1 784 posted 15 years ago by cyberhobo
Get the ID of the root (oldest ancestor, parent without parents) page relative to the current page in a WordPress page template. Can be helpful for use with wp\_list\_pages() to create navigation markup.
1 1086 posted 15 years ago by cyberhobo
There's no has\_children() function in WP 2.8.4, but get\_children() returns false if the post/page has no children, so it can serve the same purpose in a page template. Outside a page template you'd have to add a global declaration for the $post...
2 805 posted 15 years ago by cyberhobo
Create a custom 404 handler page which redirects you to the correct page.
1 708 posted 15 years ago by Meander365
1 1192 posted 15 years ago by dsheetz
0 761 posted 15 years ago by crs
Using this loop variation you can style differently the first and the last post of a loop, or whatever post you like, as lond as you add a new elseif with the number of the post you desire.
5 977 posted 15 years ago by crs
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 1842 posted 15 years ago by fouroclockproject
Completely changed original function, which stopped working around WP2.8.
1 808 posted 15 years ago by kristarella
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 757 posted 15 years ago by rickfu
In this Thesis WP tutorial for multiple custom page templates, we find code for making a custom homepage template as well.
2 823 posted 15 years ago by mlangfeld
This code to be added to custom_functions.php May also need to add to custom.css to style your custom widget. (This code found towards the end of the article).
2 873 posted 15 years ago by mlangfeld
This creates a custom HTML header in Thesis with a logo and an advert section (to be used instead of CSS image replacement). Example CSS to use with it: .custom #header:after {content:"."; display:block; height:0; clear:both; visibility:hidden;...
5 914 posted 15 years ago by kristarella
Template Tag body_class The coming WordPress 2.8 provides a new Template Tag, body_class. This function gives the body element different classes, which gives you the possibility to use it effectively with CSS.
3 611 posted 15 years ago by jessibird
This code replaces a normal category template. It sorts all posts by their category/subcategory instead of bunching them all together and ordering them by date. A bit complicated to explain in a box this size... Check the link for a run through!
1 919 posted 15 years ago by rocktronica
If you leave out the "paged" parameter, the same results are queried and shown on each pagination. Of course, you'll want to change the "3" to whichever category you'll want to exclude.
3 918 posted 15 years ago by rocktronica
1 917 posted 15 years ago by gfazioli