Skip to content

Instantly share code, notes, and snippets.

View devinsays's full-sized avatar

Devin Price devinsays

View GitHub Profile
@devinsays
devinsays / font_page_directory_query
Last active August 29, 2015 14:08
This displays a "directory" post type on the home page, sorted by the meta_key "last_name" in alphabetical order
<?php
/**
* Load 'directory' post type archive on home page
* Orderby the meta_key 'last_name' ASC
*
* Reference: http://wptheming.com/2014/10/displaying-a-custom-post-type-archive-on-the-front-page/
*/
function prefix_directory_front_page( $query ) {
// Only filter the main query on the front-end
<?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : // are there comments to navigate through ?>
<nav id="comment-nav-above" class="pagination comment-pagination" role="navigation">
<h1 class="screen-reader-text"><?php _e( 'Comment navigation', 'cascade' ); ?></h1>
<span class="page-numbers"><?php printf( __( 'Page %1$s of %2$s', 'cascade' ), ( get_query_var( 'cpage' ) ? absint( get_query_var( 'cpage' ) ) : 1 ), get_comment_pages_count() ); ?></span>
<?php paginate_comments_links(); ?>
</nav><!-- .comment-navigation -->
<?php endif; // check for comment navigation ?>
@devinsays
devinsays / photon-experiments.php
Created January 21, 2015 22:53
Photon Experiments - Image Quality
<?php
/**
* Plugin Name: Photon Experiments
* Description: Experimenting with Photon parameters.
* Version: 0.1.0
*/
if ( class_exists( 'Jetpack' ) && Jetpack::is_module_active( 'photon' ) ) :
function photon_experiments() {
@devinsays
devinsays / gist:b69da4ad3dd11cc7fc08
Last active May 26, 2017 13:55
Page Selector in Customizer
/**
* Add page selector to the customizer.
*
* @since Theme 1.0.0
*
* @param WP_Customize_Manager $wp_customize Customizer object.
*/
function prefix_customize_register( $wp_customize ) {
$wp_customize->add_section( 'showcase' , array(
@devinsays
devinsays / gist:705f9e9de5cd2a9cb16f
Created February 3, 2015 17:21
Display Page Selection in Template
<?php
// Get pages set in the customizer (if any)
$pages = array();
for ( $count = 1; $count <= 5; $count++ ) {
$mod = get_theme_mod( 'showcase-page-' . $count );
if ( 'page-none-selected' != $mod ) {
$pages[] = $mod;
}
}
@devinsays
devinsays / featured-image-meta
Last active August 29, 2015 14:15
Display Featured Image Meta
@devinsays
devinsays / ae-1-functions.php
Created March 13, 2015 16:20
ae-1-functions.php
<?php
/**
* Angular Experiments.
* Enqueue scripts and styles for the front end.
*
* @since 1.0.0
*/
function ae_scripts() {
// Load main stylesheet.
wp_enqueue_style( 'ae-style', get_stylesheet_uri() );
@devinsays
devinsays / ae-1-app.js
Created March 13, 2015 16:26
ae-1-app.js
var myapp = angular.module( 'myapp', [] );
// Set the configuration
myapp.run( ['$rootScope', function($rootScope) {
// Variables defined by wp_localize_script
$rootScope.api = aeJS.api;
}]);
@devinsays
devinsays / ae-1-index.php
Created March 13, 2015 16:32
ae-1-index.php
<div ng-controller="mycontroller">
<article ng-repeat="post in posts">
<h3>{{ post.title }}</h3>
<p>{{ post.excerpt }}</p>
</article>
</div>
<?php
/**
* Display upgrade notice on customizer page
*/
function prefix_upsell_notice() {
// Enqueue the script
wp_enqueue_script(
'prefix-customizer-upsell',
get_template_directory_uri() . '/js/upsell.js',