Alter WordPress sql tables: add a new column This code can be used during plugin activation. It first gets the results if that...
Randomize your posts Add this code snippet to your functions.php file. It jumps into the pre_get_posts hook and...
Query: exclude child categories of a specific category You can exclude children posts on your homepage of category 21 with this function. It...
Ignore sticky posts from the main query We use the pre_get_posts filter to modify the main query and set it to ignore...
Exclude sticky posts from main query Sticky posts are intended to be on top. This function excludes them from the main...
Limit CPTs per page on homepage What would we do without the pre_get_posts filter? Another handy WP snippet to customize the...
List all attachments from custom post type Sometimes you need to get all attachments (i.e. from a portfolio custom post type) and...
Add css class to last post in loop Use different css styling for your last post. This snippet adds a custom name to...
Search only in custom post types Limit the search query to a custom post type with this small snippet. We use...
Exclude posts from search by taxonomy ids A nifty function to exclude posts which contain specified term ids. Now thats one hell...