Skip to content

Instantly share code, notes, and snippets.

View senlin's full-sized avatar

Pieter Bos senlin

View GitHub Profile
@senlin
senlin / add-4th-image-different-size-to-query.php
Last active August 29, 2015 14:03
add 4th image different size to query; LinkedIn post http://lnkd.in/dbxp28Z
<?php
/**
* add 4th image different size to query; LinkedIn post http://lnkd.in/dbxp28Z
*
*/
/* Cleaner to write arguments separately; 'order_by' => 'date' is not necessary as that is the default */
$args = array(
'post_type' => 'post',
'category_name' => 'uitgelicht',
@senlin
senlin / custom_walker.php
Created June 5, 2014 05:28
Custom Walker of Flatbook theme that adds # in front of menu items to enable one-page website
<?php
/**
* Custom Walker used in Flatbook theme
*
* @source //themeforest.net/item/flatbook-flat-ebook-selling-wordpress-theme/6023410
* @ref //lnkd.in/dRjx4R6
*/
class description_walker extends Walker_Nav_Menu{
function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0){
//global $wp_query;
@senlin
senlin / slippry-slider-sample.php
Created April 8, 2014 13:37
sample to build slider with featured image with slippry
<?php
/**
* The following code is a copy of the code I recently used on the site of a client
* It uses the Aqua-Resizer script (https://github.com/syamilmj/Aqua-Resizer) to
* dynamically resize the slider images to the size needed.
*
* @source Piet Bos http://senlinonline.com
*/
echo '<div class="slider-wrapper">';
@senlin
senlin / index.php
Created March 6, 2014 00:25
Custom controls in the theme customizer using WP_Query() instead of query_posts(). Article on http://code.tutsplus.com/articles/custom-controls-in-the-theme-customizer
<div id="posts">
<?php
// Get category ID from Theme Customizer
$catID = get_theme_mod( 'tcx_category' );
// Only get Posts that are assigned to the given category ID
$args = array(
'post_type' => 'post',
'cat' => $catID
);
@senlin
senlin / episodes-feed.php
Last active December 17, 2015 20:29
Get last 5 episodes to show if "rss" custom field has been filled in. If not, output other message. See Google+ https://plus.google.com/u/0/116025569345227867532/posts/GcWYWECU7pd
<?php // Google+ post https://plus.google.com/u/0/116025569345227867532/posts/GcWYWECU7pd
include_once(ABSPATH.WPINC.'/feed.php');
{
$grss=get_post_meta($post->ID, 'rss', true);
$rss = fetch_feed($grss);
if (!is_wp_error($rss)) { // Checks that the object is created correctly
$maxitems = $rss->get_item_quantity(5);
$rss_items = $rss->get_items(0, $maxitems);
}
<?php
add_action('init', 'wptips_custom_init');
function wptips_custom_init() {
add_post_type_support( 'portfolio', array( 'page-attributes', 'comments', 'author' ) );
}
?>
<?php
add_theme_support('menus');
/*
http://codex.wordpress.org/Function_Reference/register_nav_menus#Examples
*/
register_nav_menus( array(
'main-menu' => 'Main Menu' // registers the menu in the WordPress admin menu editor
) );
@senlin
senlin / remove-welcome-panel.php
Last active December 10, 2015 16:29
In 3.5+, this hook allows you disable the Welcome Panel in the Dashboard. Removing the action also removes the corresponding Screen Option. source: http://codex.wordpress.org/Plugin_API/Action_Reference/welcome_panel
<?php
// In 3.5+, this hook allows you disable the Welcome Panel in the Dashboard.
// Removing the action also removes the corresponding Screen Option.
// source: http://codex.wordpress.org/Plugin_API/Action_Reference/welcome_panel
remove_action( 'welcome_panel', 'wp_welcome_panel' ); ?>
@senlin
senlin / highlighting-wp_nav_menu-ancestor-children-custom-post-types.php
Created December 27, 2012 13:08
Highlight the wp_nav_menu menu item when on a Custom Post Type.
<?php
// The code below finds the menu item with the class "[CPT]-menu-item" and adds another “current_page_parent” class to it.
// Furthermore, it removes the “current_page_parent” from the blog menu item, if this is present.
// Via http://vayu.dk/highlighting-wp_nav_menu-ancestor-children-custom-post-types/
add_filter('nav_menu_css_class', 'current_type_nav_class', 10, 2);
function current_type_nav_class($classes, $item) {
// Get post_type for this post
$post_type = get_query_var('post_type');
@senlin
senlin / Contract Killer 3.md
Last active October 13, 2015 15:37 — forked from malarkey/Contract Killer 3.md
The latest version of my ‘killer contract’ for web designers and developers

Contract Killer 3

Revised date: 07/11/2012

Between us [company name] and you [customer name]

Summary:

We’ll always do our best to fulfil your needs and meet your expectations, but it’s important to have things written down so that we both know what’s what, who should do what and when, and what will happen if something goes wrong. In this contract you won’t find any complicated legal terms or long passages of unreadable text. We’ve no desire to trick you into signing something that you might later regret. What we do want is what’s best for both parties, now and in the future.