Skip to content

Instantly share code, notes, and snippets.

@jhebb
jhebb / Truncate.Filter.js
Created February 15, 2016 13:48 — forked from CMCDragonkai/Truncate.Filter.js
JS: AngularJS Truncate Filter for Words and Characters. Adapted from https://github.com/sparkalow/angular-truncate
define(['angular'], function(angular){
'use strict';
/**
* Truncates characters or words. Truncate characters by default does not truncates on a word.
*/
angular.module('Filters')
.filter('TruncateCharacters', [
function(){
@jhebb
jhebb / is_blog.php
Last active December 16, 2015 02:59 — forked from wesbos/is_blog.php
Add is_blog() function to WordPress
function is_blog () {
global $post;
$posttype = get_post_type($post );
return ( ( is_archive() || is_home() || is_single() ) && ( $posttype == 'post') ) ? true : false ;
}
Usage:
<?php if (is_blog()) { echo 'You are on a blog page'; } ?>
@jhebb
jhebb / Custom Taxonomy Markup
Last active December 12, 2015 01:08 — forked from johnbhartley/Custom Tax
Show custom taxonomy with custom markup
<?php
$query = new WP_Query(array('post_type' => 'custom-post-type'));
while ($query->have_posts()) : $query->the_post();
$terms = get_the_terms( $post->id, 'custom-taxonomy' ); // registered custom taxonomy in custom post type
if( $terms && ! is_wp_error( terms ) ) {
foreach( $terms as $term ) {
echo '<a class="term-' . $term->slug . '" href="' . get_term_link($term) . '" title="' . $term->name .'">' . $term->name .'</a>';
}
}