Skip to content

Instantly share code, notes, and snippets.

@remkus
remkus / gist:1234987
Created September 22, 2011 14:56
Poor Coding standards - or even, lack thereof
<?php
function custom_body_class($classes) {
if (!is_user_logged_in())
$classes[] = 'not-loggedin';
return $classes;
}
add_filter('body_class','custom_body_class');
@remkus
remkus / gist:1235165
Created September 22, 2011 16:02
Example of WordPress coding standards
<?php
add_filter( 'body_class' , 'ft_add_guest_body_class' );
/**
* Adds a body class for guests.
*
* @author Remkus de Vries
* @link http://remkusdevries.com/when-sharing-wordpress-related-code-snippets-i-can-haz-standards-please/
* @param array $classes Existing body classes
* @return array Amended body classes
@remkus
remkus / gist:1770438
Created February 8, 2012 15:26
Custom Post Type
<?php
/**
* Custom Post Type with matching Custom Taxonomy. Only thing missing is how to
* get the following permalink: /tips/taxonomy-name/postname
*
*/
register_post_type( 'Tips', array(
'label' => 'Tips',
@remkus
remkus / gist:1870417
Created February 20, 2012 18:13
Adding Custom Fields to Custom Post Type feed
<?php
add_filter( 'the_content_rss', 'iculture_add_custom_fields_to_apptopvijf_content' );
add_filter( 'the_content', 'iculture_add_custom_fields_to_apptopvijf_content' );
/**
* Alter the content output for the apptovijf custom post type.
*
* @global $post Post object
* @param string $content Existing content.
* @return string Filtered content.
@remkus
remkus / wp_editor_extra_wp-admin-bar-menu.php
Created February 23, 2012 14:03 — forked from jphorn/wp_editor_extra_wp-admin-bar-menu.php
Add menu to WordPress Admin Bar for Editor role (and higher) (WordPress Toolbar)
<?php
/**
* Adding a menu to your WordPress Toolbar
*
* @author: Jean-Paul Horn, iCulture.nl (@JeanPaulH)
* @param $wp_admin_bar used to add an extra dropdown menu
*
* Thanks to Remkus de Vries (@defries)
*/
@remkus
remkus / gist:2157116
Created March 22, 2012 08:23
Adding Widget Area in between Grid
<?php
add_action( 'genesis_after_post','ecowijs_add_widget_area_between_grid' );
/**
* The ecowijs_add_widget_area_between_grid function is all about
* dAdding Widget Area between Genesis Featured and Genesis Gri
*
* @access public
* @return void
*/
@remkus
remkus / add-menu.php
Created March 22, 2012 18:59
Pre populate Custom Menus
<?php
add_action( 'init', 'add_menus' );
function add_menus() {
register_nav_menus( array( 'main_nav' =--> 'The main menu', ) );
$new_menu_id = wp_create_nav_menu( 'Main Menu' );
@remkus
remkus / rkv_date_convert
Created April 1, 2012 17:32 — forked from norcross/rkv_date_convert
Convert date entry to UNIX timestamp
// Make two admin-only fields (as text fields)
// and post to the custom fields from Gravity Forms
// instead of the "real" date picker.
// NOTE: change the input IDs to match the ones on your form
function rkv_datesubmit_fix ($form){
//event start date field id is 3
//event end date field ID is 4
$raw_srt = $_POST['input_3'];
$raw_end = $_POST['input_4'];
<?php
add_filter( 'genesis_author_box', 'zip_author_box', 10, 6 );
/**
* Filters author box by adding extra link
*
* @access public
* @param mixed $output
* @param mixed $context
* @param mixed $pattern
@remkus
remkus / gist:2580322
Created May 2, 2012 20:42
Filter one Post Format via a Custom Loop.
<?php
$args = array(
'post_type' => 'post',
'post_status' => 'publish',
'order' => 'DESC',
'tax_query' => array(
array(
'taxonomy' => 'post_format',
'field' => 'slug',