Skip to content

Instantly share code, notes, and snippets.

View jonathanfann's full-sized avatar

Jonathan Fann jonathanfann

View GitHub Profile
@jonathanfann
jonathanfann / diff-header-per-custom-post-type.php
Created February 15, 2017 23:05
Include Different Header For Each Custom Post Type
<?php
$post_type = get_post_type( get_the_ID() );
get_template_part( 'headers/' . $post_type, 'header' );
?>
<!--
if your custom post type label is named 'support' for example
this will include the contents of 'yourtheme/headers/support-header.php'
Note: Fails silently so if file doesn't exist, nothing will be included.
-->
@jonathanfann
jonathanfann / gist_wordpress_shortcode.php
Last active October 21, 2016 14:03
Wordpress Gist Shortcode
// Add Shortcode to your functions.php
function gist_shortcode( $atts ) {
// Attributes
$atts = shortcode_atts(
array(
'name' => 'jonathanfann',
'slug' => 'ae707752f2f2c3f93e739838f8dce5c0',
),
[fields.body]
label = Body
type = markdown
{% for k,v in bag('career.quotes').iteritems() %}
<div id="{{ k }}">
<div class="quote">
<h3>"{{ v.quote }}"</h3>
<p><em>{{ v.name }}, {{ v.title }}</em></p>
</div>
</div>
{% endfor %}
@jonathanfann
jonathanfann / lektor_nav_list.html
Last active October 21, 2016 14:45
Navigation Example in Lektor (Jinja-like Pythonic Static Site Generator)
{% set root = site.get('/business') %}
{% for child in root.children.order_by('id', 'title') %}
<li>
<a href="{{ child|url }}">{{ child.title }}</a>
</li>
{% endfor %}