Skip to content

Instantly share code, notes, and snippets.

@bradpotter
bradpotter / page-title-1.html
Last active February 18, 2016 19:22
Page title 1 or 2
<div class="site-inner">
<div class="content-sidebar-wrap">
<header class="entry-header">
<h1 class="entry-title" itemprop="headline">Sample Page</h1>
</header>
<main class="content" id="genesis-content">
<article class="post-31 page type-page status-publish entry" itemscope="" itemtype="http://schema.org/CreativeWork">
<div class="entry-content" itemprop="text">
@bradpotter
bradpotter / widget-template-1.php
Last active August 29, 2015 14:21
Page template to use with auto sidebar registration
<?php
/**
* This file adds the Custom Widget Page Template to ThemeCore.
*
* @author Brad Potter
* @package ThemeCore
* @subpackage Customizations
*/
/*
@bradpotter
bradpotter / widget-template-1.php
Last active August 29, 2015 14:21
Page template to use with auto sidebar registration
<?php
/**
* This file adds the Custom Widget Page Template to ThemeCore.
*
* @author Brad Potter
* @package ThemeCore
* @subpackage Customizations
*/
/*
@bradpotter
bradpotter / functions.php
Last active August 29, 2015 14:21
Register a sidebar for a page that has a page template selected
add_action('widgets_init', 'gpb_register_sidebar');
/**
* Dynamically register sidebar for pages that use specified template
*
*/
function gpb_register_sidebar() {
global $post;
global $wp_registered_sidebars;
// Find all pages that use template with dynamic sidebar
@bradpotter
bradpotter / functions.php
Last active August 29, 2015 14:20
Filter term meta
add_filter( 'genesis_term_meta_defaults', 'add_term_meta_defaults' );
function add_term_meta_defaults( $term_meta ) {
$more_term_meta = array(
'my_new_default' => '',
);
$term_meta = array_merge( $more_term_meta, $term_meta );
return $term_meta;
@bradpotter
bradpotter / gist:9084667a8ec826ec9dd6
Created April 23, 2015 18:54
Modify the main query based on tag
//* Modify the main query based on tag
add_action( 'pre_get_posts','custom_tax_query' );
function custom_tax_query( $query ) {
if ( $query->is_main_query() && $query->is_tag( 'west-valley-2015' ) ) {
$query->set( 'posts_per_page', '3' );
$query->set( 'order', 'ASC' );
$query->set( 'orderby', 'title' );
}
}
@bradpotter
bradpotter / functions.php
Last active August 29, 2015 14:15
Filter body_class using conditional and custom field in order to change post or page layout. Requires appropriate css.
add_filter( 'body_class', 'my_class_names' );
function my_class_names( $classes ) {
global $post;
$layout = get_post_meta($post->ID, 'layout', true);
if ( is_singular() && $layout == 'sidebar-content' ) {
$classes[] = 'sidebar-content';
}
@bradpotter
bradpotter / header.php
Last active August 29, 2015 14:15
Change body class via a custom field value in order to change post or page layout
<body <?php
$layout = get_post_meta($post->ID, 'layout', true);
if ( is_singular() && $layout == 'sidebar-content' ) {
body_class( 'sidebar-content' );
}
elseif ( is_singular() && $layout == 'full-width-content' ) {
function my_custom_loop() {
$args = array(
'category_name' => 'featured',
'orderby' => 'post_date',
'order' => 'DESC',
'posts_per_page'=> '3',
);
$loop = new WP_Query( $args );
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query#Parameters
* Source: https://core.trac.wordpress.org/browser/tags/3.9/src/wp-includes/query.php
*/
$args = array(