Skip to content

Instantly share code, notes, and snippets.

@Sjouw
Sjouw / cf7-plugin.php
Created June 30, 2015 08:13
Contact Form 7 (3.8) - change recipient based on zipcode
<?php
/*
Plugin Name: Contact Form 7 Zipcode check
Plugin URI: http://youruri.com/
Description:
Author:
Version: 1.0
Author URI:
*/
@Sjouw
Sjouw / functions.php
Created February 10, 2015 15:39
WordPress - Show dynamic menu title above menu
function get_theme_menu_name( $theme_location ) {
if ( !has_nav_menu( $theme_location ) ) return false;
$menus = get_nav_menu_locations();
$menu_title = wp_get_nav_menu_object( $menus[$theme_location] )->name;
return $menu_title;
}
@Sjouw
Sjouw / latest-posts.php
Created December 18, 2014 16:02
WordPress - Sidebar latest posts widget with toggle dropdown for small screens
<?php
// Get the poststype of the current post
$posttype = get_post_type();
$obj = get_post_type_object( $posttype );
$args = array (
'post_type' => $posttype,
'post_status' => 'publish',
'post_count' => 5
@Sjouw
Sjouw / latest-posts.php
Created December 18, 2014 15:19
WordPress - Better latest posts sidebar menu widget with active states
<?php
// Get the poststype of the current post
$posttype = get_post_type();
$obj = get_post_type_object( $posttype );
$args = array (
'post_type' => $posttype,
'post_status' => 'publish',
'post_count' => 5
@Sjouw
Sjouw / custom.php
Created December 9, 2014 12:57
WordPress - Add description to featured image field
/*
* Add description to Featured image box
*/
function new_post_thumbnail_meta_box() {
global $post;
$thumbnail_id = get_post_meta( $post->ID, '_thumbnail_id', true ); // grabing the thumbnail id of the post
echo _wp_post_thumbnail_html( $thumbnail_id ); // echoing the html markup for the thumbnail
@Sjouw
Sjouw / checkbox.html
Last active August 29, 2015 14:07
CSS yes/no switch from checkbox
<div class="checkbox-wrap">
<input name="checkbox1" type="checkbox" value="Yes" checked="checked" id="checkbox1">
<label for="checkbox1" id="label1">Yes</label>
</div>
@Sjouw
Sjouw / custom.php
Last active August 29, 2015 14:07
Quickscan with redirect to resultpage (using Gravity Forms)
/**
* We calculate the input value of give form inputs and change the redirect url afterwards
*
* @param array $form, array $lead
*
* @return array $confirmation[ 'redirect' ]
**/
add_filter( 'gform_confirmation', 'custom_confirmation', 10, 4 );