Skip to content

Instantly share code, notes, and snippets.

Avatar

Kees Meijer keesiemeijer

View GitHub Profile
@keesiemeijer
keesiemeijer / functions.php
Created Jan 26, 2013
Adds filters to a query
View functions.php
<?php
// don't use the php tags when copying this in your own theme's functions.php
function add_new_query_vars($public_query_vars) {
$public_query_vars[] = 'posts_fields';
$public_query_vars[] = 'posts_join';
$public_query_vars[] = 'posts_where';
$public_query_vars[] = 'posts_orderby';
return $public_query_vars;
}
@keesiemeijer
keesiemeijer / gist:6498235
Last active Feb 3, 2017
Adds WordPress top level admin menu items to the toolbar (admin bar) on the front end.Adds post types items and their taxonomies to the toolbar on the front end.Items are added based on the current users capabilities.
View gist:6498235
<?php
/**
* Add back end wp-admin menu items to the front end toolbar 'site-name' node.
* Menu items are added based on the current users capabilities.
*/
class KM_WP_Admin_Bar_Front_End_Menu {
/**
* Prefix for toolbars ids
@keesiemeijer
keesiemeijer / gist:7563447
Last active Mar 18, 2021
Gets date ranges for the BETWEEN operator in a WordPress meta query
View gist:7563447
<?php
/**
* Gets date ranges for the BETWEEN operator in a WordPress meta query.
* WordPress minimum requirements don't let you
* use php DateTime or (some) relative formats for strtotime() which were introduced in php 5.3.
*
* @param string|array $args Arguments.
* @return array Array with two dates.
*/
function get_between_clause_dates( $args ) {
@keesiemeijer
keesiemeijer / gist:9320762
Created Mar 3, 2014
WordPress: Checks if new post is created
View gist:9320762
<?php
/**
* Checks if post status is new
*/
add_action( 'transition_post_status', 'post_unpublished', 10, 3 );
function post_unpublished( $new_status, $old_status, $post ) {
if ( $old_status == 'new' ) {
// do stuff for new post
}
@keesiemeijer
keesiemeijer / reversed-pagination.php
Last active Aug 29, 2015
Reversed WordPress Pagination
View reversed-pagination.php
<?php
/**
* Reversed Pagination for WordPress - proof of concept
*
* WARNING! Not suitable for use on a live website!
*
* Proof of concept for reversed pagination as discussed here
* http://nerd.vasilis.nl/problem-paginated-archive-pages-blogs/
* and here (Dutch)
* http://wasstra.at/035/
@keesiemeijer
keesiemeijer / poc-related-posts.php
Last active Aug 29, 2015
Proof of concept to get related words from WordPress post title and filename.
View poc-related-posts.php
@keesiemeijer
keesiemeijer / poc-related-words-functions.html
Created Dec 12, 2014
Output for proof of concept to get related words from WordPress post title and filename. Functions.
View poc-related-words-functions.html
@keesiemeijer
keesiemeijer / poc-related-words-classes.html
Created Dec 12, 2014
Output for proof of concept to get related words from WordPress post title and filename. Classes
View poc-related-words-classes.html
@keesiemeijer
keesiemeijer / poc-related-words-methods.html
Created Dec 12, 2014
Output for proof of concept to get related words from WordPress post title and filename. Methods
View poc-related-words-methods.html
@keesiemeijer
keesiemeijer / poc-related-words-hooks.html
Created Dec 12, 2014
Output for proof of concept to get related words from WordPress post title and filename. Hooks.
View poc-related-words-hooks.html