Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Kellen Genesis Theme
<?php
/**
* Template Name: Kellen Clients Archive
* Description: ...
*/
//* Show page content above posts
add_action( 'genesis_loop', 'genesis_standard_loop', 5 );
genesis();
<?php
/**
* Template Name: Kellen People Archive
* Description: "Our People" category
*/
add_action('genesis_before_entry_content', 'our_people_tags');
function our_people_tags() {
// Nav Menu Dropdown Class
include_once( CHILD_DIR . '/lib/classes/nav-menu-dropdown.php' );
wp_nav_menu( array(
// 'theme_location' => 'mobile',
'menu' => 'dd - cpt - Our People',
'walker' => new Walker_Nav_Menu_Dropdown(),
'items_wrap' => '<div class="mobile-menu"><form><select onchange="if (this.value) window.location.href=this.value">%3$s</select></form></div>',
) );
}
genesis();
<?php
/**
* This file adds the Home Page to the KellenCo Theme.
*
* @author JasonAbney
* @package KellenCo
* @subpackage Customizations
*/
add_action( 'genesis_meta', 'kellenco_front_page_genesis_meta' );
/**
* Add widget support for homepage. If no widgets active, display the default loop.
*
*/
function kellenco_front_page_genesis_meta() {
if ( is_active_sidebar( 'front-page-1' ) || is_active_sidebar( 'front-page-2' ) || is_active_sidebar( 'front-page-3' ) || is_active_sidebar( 'front-page-4' ) || is_active_sidebar( 'front-page-5' ) || is_active_sidebar( 'front-page-6' ) ) {
add_action( 'wp_enqueue_scripts', 'custom_load_custom_style_sheet' );
function custom_load_custom_style_sheet() {
wp_enqueue_style( 'custom-stylesheet', CHILD_URL . '/lib/carousel.css', array(), PARENT_THEME_VERSION );
}
//* Enqueue scripts
add_action( 'wp_enqueue_scripts', 'kellenco_enqueue_kellenco_script' );
function kellenco_enqueue_kellenco_script() {
wp_enqueue_script( 'kellenco-script', get_bloginfo( 'stylesheet_directory' ) . '/js/home.js', array( 'jquery' ), '1.0.0' );
wp_enqueue_script( 'localScroll', get_stylesheet_directory_uri() . '/js/jquery.localScroll.min.js', array( 'scrollTo' ), '1.2.8b', true );
wp_enqueue_script( 'scrollTo', get_stylesheet_directory_uri() . '/js/jquery.scrollTo.min.js', array( 'jquery' ), '1.4.5', true );
wp_enqueue_script( 'bootstrap', get_stylesheet_directory_uri() . '/js/bootstrap.min.js', array( 'jquery' ), '1.4.5', true );
}
//* Add front-page body class
add_filter( 'body_class', 'kellenco_body_class' );
function kellenco_body_class( $classes ) {
$classes[] = 'front-page';
return $classes;
}
//* Force full width content layout
add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' );
//* Remove breadcrumbs
remove_action( 'genesis_before_loop', 'genesis_do_breadcrumbs' );
//* Remove the default Genesis loop
remove_action( 'genesis_loop', 'genesis_do_loop' );
//* Add homepage widgets
add_action( 'genesis_loop', 'kellenco_front_page_widgets' );
//* Add featured-section body class
if ( is_active_sidebar( 'front-page-1' ) ) {
//* Add image-section-start body class
add_filter( 'body_class', 'kellenco_featured_body_class' );
function kellenco_featured_body_class( $classes ) {
$classes[] = 'featured-section';
return $classes;
}
}
}
}
//* Add markup for front page widgets
function kellenco_front_page_widgets() {
genesis_widget_area( 'front-page-1', array(
'before' => '<div id="front-page-1" class="front-page-1"><div class="image-section"><div class="flexible-widgets widget-area' . kellenco_widget_area_class( 'front-page-1' ) . '"><div class="wrap">',
'after' => '</div></div></div></div>',
) );
genesis_widget_area( 'front-page-2', array(
'before' => '<div id="front-page-2" class="front-page-2"><div class="solid-section"><div class="flexible-widgets widget-area' . kellenco_widget_area_class( 'front-page-2' ) . '"><div class="wrap">',
'after' => '</div></div></div></div>',
) );
genesis_widget_area( 'front-page-3', array(
'before' => '<div id="front-page-3" class="front-page-3"><div class="image-section"><div class="flexible-widgets widget-area' . kellenco_widget_area_class( 'front-page-3' ) . '"><div class="wrap">',
'after' => '</div></div></div></div>',
) );
genesis_widget_area( 'front-page-4', array(
'before' => '<div id="front-page-4" class="front-page-4"><div class="solid-section"><div class="flexible-widgets widget-area' . kellenco_widget_area_class( 'front-page-4' ) . '"><div class="wrap">',
'after' => '</div></div></div></div>',
) );
genesis_widget_area( 'front-page-5', array(
'before' => '<div id="front-page-5" class="front-page-5"><div class="image-section"><div class="flexible-widgets widget-area' . kellenco_widget_area_class( 'front-page-5' ) . '"><div class="wrap">',
'after' => '</div></div></div></div>',
) );
genesis_widget_area( 'front-page-6', array(
'before' => '<div id="front-page-6" class="front-page-6"><div class="solid-section"><div class="flexible-widgets widget-area' . kellenco_widget_area_class( 'front-page-6' ) . '"><div class="wrap">',
'after' => '</div></div></div></div>',
) );
genesis_widget_area( 'front-page-7', array(
'before' => '<div id="front-page-7" class="front-page-7"><div class="image-section"><div class="flexible-widgets widget-area' . kellenco_widget_area_class( 'front-page-7' ) . '"><div class="wrap">',
'after' => '</div></div></div></div>',
) );
}
genesis();
/**
* Return Archive Section
* @author Bill Erickson
* @link http://www.billerickson.net/code/helper-function-for-template-include-and-body-class/
*
* @param null
* @return string
*/
function be_return_archive_section() {
if( is_post_type_archive( 'kellen_clients' ) || is_tax( 'client_category' ) )
return 'kellen_clients';
if( is_post_type_archive( 'kellen_people' ) || is_tax( 'people-category' ) )
return 'kellen_people';
return false;
}
add_filter( 'template_include', 'be_template_chooser' );
/**
* Template Chooser
* Use CPT archive templates for taxonomies
* @author Bill Erickson
* @link http://www.billerickson.net/code/use-same-template-for-taxonomy-and-cpt-archive/
*
* @param string, default template path
* @return string, modified template path
*
*/
function be_template_chooser( $template ) {
if ( be_return_archive_section() )
$template = get_query_template( 'archive-' . be_return_archive_section() );
return $template;
}
add_filter( 'body_class', 'be_section_body_classes' );
/**
* Section Body Classes
* @author Bill Erickson
*
* @param array $classes
* @return array
*/
function be_section_body_classes( $classes ) {
if( be_return_archive_section() )
$classes[] = 'section-' . be_return_archive_section();
return $classes;
}
<?php
//* Start the engine
include_once( get_template_directory() . '/lib/init.php' );
//* Setup Theme
include_once( get_stylesheet_directory() . '/lib/theme-defaults.php' );
//* Add Image upload and Color select to WordPress Theme Customizer
require_once( get_stylesheet_directory() . '/lib/customize.php' );
//* Include Customizer CSS
include_once( get_stylesheet_directory() . '/lib/output.php' );
//* Child theme (do not remove)
define( 'CHILD_THEME_NAME', 'Genesis Child Theme for the Kellen Company.' );
define( 'CHILD_THEME_URL', 'http://www.jasonabney.com/' );
define( 'CHILD_THEME_VERSION', '1.0.0' );
//* Enqueue Scripts and Google Fonts
add_action( 'wp_enqueue_scripts', 'kellenco_enqueue_scripts' );
function kellenco_enqueue_scripts() {
wp_enqueue_script( 'kellenco-global', get_bloginfo( 'stylesheet_directory' ) . '/js/global.js', array( 'jquery' ), '1.0.0' );
wp_enqueue_script( 'kellenco-responsive-menu', get_bloginfo( 'stylesheet_directory' ) . '/js/responsive-menu.js', array( 'jquery' ), '1.0.0' );
wp_enqueue_style( 'dashicons' );
wp_enqueue_style( 'google-fonts', '//fonts.googleapis.com/css?family=Lato:300,400,700,300italic,400italic,700italic', array(), CHILD_THEME_VERSION );
wp_enqueue_style( 'font-awesome', '//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.min.css', array(), '4.0.3' );
}
//* Add HTML5 markup structure
add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list' ) );
//* Add viewport meta tag for mobile browsers
add_theme_support( 'genesis-responsive-viewport' );
//* Add support for custom background
add_theme_support( 'custom-background' );
// Add new image sizes
add_image_size( 'sidebar-thumbnail', 60, 60, true );
add_image_size( 'insights-thumbnail', 225, 225, true );
//add_image_size( 'home-feature', 740, 432, true );
//add_image_size( 'portfolio-thumbnail', 540, 315, true );
//add_image_size( 'portfolio-feature', 1024, 597, true );
//* Add support for 3-column footer widgets
add_theme_support( 'genesis-footer-widgets', 3 );
//* Remove footer
remove_action( 'genesis_footer', 'genesis_do_footer' );
//* Reposition the primary navigation menu
remove_action( 'genesis_after_header', 'genesis_do_nav' );
add_action( 'genesis_before_content_sidebar_wrap', 'genesis_do_nav' );
//* Reposition the secondary navigation menu
remove_action( 'genesis_after_header', 'genesis_do_subnav' );
//* Add support for structural wraps
add_theme_support( 'genesis-structural-wraps', array(
'header',
'nav',
'subnav',
'footer-widgets',
'footer',
) );
//* Add support for column classes in the editor.
//* http://www.billerickson.net/using-column-classes/
add_editor_style( 'editor-style.css' );
//* Setup widget counts
function kellenco_count_widgets( $id ) {
global $sidebars_widgets;
if ( isset( $sidebars_widgets[ $id ] ) ) {
return count( $sidebars_widgets[ $id ] );
}
}
function kellenco_widget_area_class( $id ) {
$count = kellenco_count_widgets( $id );
$class = '';
if( $count == 1 ) {
$class .= ' widget-full';
} elseif( $count % 3 == 1 ) {
$class .= ' widget-thirds';
} elseif( $count % 4 == 1 ) {
$class .= ' widget-fourths';
} elseif( $count % 2 == 0 ) {
$class .= ' widget-halves uneven';
} else {
$class .= ' widget-halves';
}
return $class;
}
// Create Client Categories taxonomy to use with Kellen_Clients custom post type
add_action( 'init', 'create_clients_taxonomy', 0 );
function create_clients_taxonomy() {
$labels = array(
'name' => _x( 'Client Categories', 'taxonomy general name' ),
'singular_name' => _x( 'Client Category', 'taxonomy singular name' ),
'search_items' => __( 'Search Client Categories' ),
'all_items' => __( 'All Client Categories' ),
'parent_item' => __( 'Parent Client Category' ),
'parent_item_colon' => __( 'Parent Client Category:' ),
'edit_item' => __( 'Edit Client Category' ),
'update_item' => __( 'Update Client Category' ),
'add_new_item' => __( 'Add New Client Category' ),
'new_item_name' => __( 'New Client Category Name' ),
'menu_name' => __( 'Client Categories' ),
);
register_taxonomy('client_category',array('kellen_clients'), array(
'hierarchical' => true,
'labels' => $labels,
'has_archive' => true,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'client-category' ),
));
}
//* Create Clients custom post type
add_action( 'init', 'create_client_type' );
function create_client_type() {
$labels = array(
'name' => 'Clients',
'singular_name' => 'Client',
'add_new' => 'Add New',
'add_new_item' => 'Add New Client',
'edit_item' => 'Edit Client',
'new_item' => 'New Client',
'view_item' => 'View Client',
'search_items' => 'Search Clients',
'not_found' => 'No ebooks found',
'not_found_in_trash' => 'No Clients found in trash',
'parent_item_colon' => '',
'menu_name' => 'Clients'
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => array('slug' => 'clients'),
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => false,
'menu_position' => null,
'menu_icon' => 'dashicons-admin-users',
'taxonomies' => array( 'client_category' ),
'supports' => array('title','thumbnail','editor', 'genesis-cpt-archives-settings')
);
register_post_type( 'kellen_clients', $args );
}
//* Create Our People custom taxonomy
add_action( 'init', 'kellen_people_type_taxonomy' );
function kellen_people_type_taxonomy() {
register_taxonomy('people-category',array('kellen_people'),
array(
'labels' => array(
'name' => _x( 'People Categories', 'taxonomy general name', 'kellenco' ),
'add_new_item' => __( 'Add New People Category', 'kellenco' ),
'new_item_name' => __( 'New People Category', 'kellenco' ),
),
'exclude_from_search' => true,
'has_archive' => true,
'hierarchical' => true,
'rewrite' => array(
'slug' => 'people-category',
'with_front' => false,
'hierarchical' => true
),
'show_ui' => true,
'show_tagcloud' => false,
)
);
}
//* Create Our People custom post type
add_action( 'init', 'kellen_people_post_type' );
function kellen_people_post_type() {
register_post_type( 'kellen_people',
array(
'labels' => array(
'name' => __( 'Our People', 'kellenco' ),
'singular_name' => __( 'Our People', 'kellenco' ),
),
'taxonomies' => array( 'people-category' ),
'exclude_from_search' => true,
'has_archive' => true,
'hierarchical' => true,
'menu_icon' => 'dashicons-admin-users',
'public' => true,
'rewrite' => array(
'slug' => 'kellen-people',
'with_front' => false
),
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'custom-fields', 'revisions', 'page-attributes', 'genesis-seo', 'genesis-cpt-archives-settings' ),
)
);
}
/**
* Return Archive Section
* @author Bill Erickson
* @link http://www.billerickson.net/code/helper-function-for-template-include-and-body-class/
*
* @param null
* @return string
*/
function be_return_archive_section() {
if( is_post_type_archive( 'kellen_clients' ) || is_tax( 'client_category' ) )
return 'kellen_clients';
if( is_post_type_archive( 'kellen_people' ) || is_tax( 'people-category' ) )
return 'kellen_people';
return false;
}
add_filter( 'template_include', 'be_template_chooser' );
/**
* Template Chooser
* Use CPT archive templates for taxonomies
* @author Bill Erickson
* @link http://www.billerickson.net/code/use-same-template-for-taxonomy-and-cpt-archive/
*
* @param string, default template path
* @return string, modified template path
*
*/
function be_template_chooser( $template ) {
if ( be_return_archive_section() )
$template = get_query_template( 'archive-' . be_return_archive_section() );
return $template;
}
add_filter( 'body_class', 'be_section_body_classes' );
/**
* Section Body Classes
* @author Bill Erickson
*
* @param array $classes
* @return array
*/
function be_section_body_classes( $classes ) {
if( be_return_archive_section() )
$classes[] = 'section-' . be_return_archive_section();
return $classes;
}
//* Register widget areas
genesis_register_sidebar( array(
'id' => 'front-page-1',
'name' => __( 'Front Page 1', 'kellenco' ),
'description' => __( 'This is the front page 1 section.', 'kellenco' ),
) );
genesis_register_sidebar( array(
'id' => 'front-page-2',
'name' => __( 'Front Page 2', 'kellenco' ),
'description' => __( 'This is the front page 2 section.', 'kellenco' ),
) );
genesis_register_sidebar( array(
'id' => 'front-page-3',
'name' => __( 'Front Page 3', 'kellenco' ),
'description' => __( 'This is the front page 3 section.', 'kellenco' ),
) );
genesis_register_sidebar( array(
'id' => 'front-page-4',
'name' => __( 'Front Page 4', 'kellenco' ),
'description' => __( 'This is the front page 4 section.', 'kellenco' ),
) );
genesis_register_sidebar( array(
'id' => 'front-page-5',
'name' => __( 'Front Page 5', 'kellenco' ),
'description' => __( 'This is the front page 5 section.', 'kellenco' ),
) );
genesis_register_sidebar( array(
'id' => 'front-page-6',
'name' => __( 'Front Page 6', 'kellenco' ),
'description' => __( 'This is the front page 6 section.', 'kellenco' ),
) );
/**
* Button Shortcode
* @link http://www.billerickson.net/using-shortcodes/
* @author Bill Erickson
*
* @param array attributes
* @param string button text
* @return string button
*/
function be_button_shortcode( $atts, $content = 'Click Here' ) {
extract(shortcode_atts(array(
'color' => 'blue',
'url' => '#'
), $atts));
$button = '<a class="button color-' . esc_attr( $color ) . '" href="' . esc_url( $url ) . '">' . esc_attr( $content ) . '</a>';
return $button;
}
add_shortcode( 'button', 'be_button_shortcode' );
//Font Awesome Shortcodes
function shortcode_icon( $atts ){
extract( shortcode_atts( array(
'class' => '',
), $atts ) );
if( !empty( $class ) ){
$fa_exists = false;
$class_array = explode( ' ', $class );
foreach( $class_array as $c ){
if( 'fa' == $c ){
$fa_exists = true;
}
}
if( !$fa_exists ){
array_unshift( $class_array, 'fa' );
}
return '<i class="'.implode( ' ', $class_array ).'"></i>';
}
}
function shortcode_stack( $atts, $content = null ){
extract( shortcode_atts( array(
'class' => '',
), $atts ) );
if( empty( $class ) ){
$class_array = array( 'fa-stack' );
} else {
$fa_stack_exists = false;
$class_array = explode( ' ', $class );
foreach( $class_array as $c ){
if( 'fa-stack' == $c ){
$fa_stack_exists = true;
}
}
if( !$fa_stack_exists ){
array_unshift( $class_array, 'fa-stack' );
}
}
return '<span class="'.implode( ' ', $class_array ).'">'.do_shortcode( $content ).'</span>';
}
function menu_parse_shortcodes( $items ) {
foreach ( $items as $item ) {
$item->title = do_shortcode($item->title);
}
return $items;
}
add_filter( 'wp_nav_menu_objects', 'menu_parse_shortcodes' );
add_shortcode( 'fa', 'shortcode_icon' );
add_shortcode( 'fa-stack', 'shortcode_stack' );
//* Adding search form
add_action('genesis_before_content', 'kellen_toggle_search');
function kellen_toggle_search(){
echo '<div class="search-wrap hide" id="toggle-search">' . "\n";
echo get_search_form();
echo '</div>' . "\n";
}
//* Used to get the content with formating...
function get_the_content_with_formatting ($more_link_text = '(more...)', $stripteaser = 0, $more_file = '') {
$content = get_the_content($more_link_text, $stripteaser, $more_file);
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]&gt;', $content);
return $content;
}
<?php
//* Template Name: Insights Template
//* Show page content above posts
add_action( 'genesis_loop', 'genesis_standard_loop', 5 );
// Force layout on category
add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_content_sidebar' );
//* Remove the entry meta in the entry header
remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_open', 5 );
remove_action( 'genesis_entry_header', 'genesis_post_info', 12 );
remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_close', 15 );
//* Add custom body class to the head
add_filter( 'body_class', 'sp_body_class' );
function sp_body_class( $classes ) {
$classes[] = 'insights-page';
return $classes;
}
//
remove_action( 'genesis_entry_header', 'genesis_do_post_title' );
add_action('genesis_entry_header', 'kellen_insights_title');
function kellen_insights_title(){
if ( !is_page( 136 ) ) {
echo '<h2 class="insights-page-title">Insights</h2>';
}
}
add_action( 'genesis_entry_header', 'genesis_do_post_title' );
// Add our custom loop
remove_action( 'genesis_loop', 'genesis_do_loop' );
add_action( 'genesis_loop', 'insights_post_loop' );
function insights_post_loop() {
$include = genesis_get_option( 'blog_cat' );
$exclude = genesis_get_option( 'blog_cat_exclude' ) ? explode( ',', str_replace( ' ', '', genesis_get_option( 'blog_cat_exclude' ) ) ) : '';
$paged = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;
$separator = '&rsaquo;';
//* Easter Egg
$query_args = wp_parse_args(
genesis_get_custom_field( 'query_args' ),
array(
'cat' => $include,
'category__not_in' => $exclude,
//'showposts' => genesis_get_option( 'blog_cat_num' ),
'paged' => $paged,
)
);
$loop = new WP_Query( $query_args );
if( $loop->have_posts() ) {
// loop through posts
while( $loop->have_posts() ): $loop->the_post();
echo '<div class="insights-posts">';
echo '<div class="three-fourths first">';
echo '<p class="insights-posts-date">' . get_the_modified_date() . '</p>';
echo '<h2 class="insights-post-title"><a href="' . get_permalink() .'" title="' . the_title_attribute( 'echo=0' ) . '">' . get_the_title() . '</a></h2>';
echo '<p>' . wp_trim_words( get_the_content(), 60 ) . '</p>';
//echo '<p><a href="' . get_permalink() .'" title="' . the_title_attribute( 'echo=0' ) . '">More <i class="fa fa-caret-right"></i></a></p>';
echo '</div>';
echo '<div class="one-fourth">';
the_post_thumbnail('insights-thumbnail');
echo '</div>';
echo '<div class="first">';
$categories = get_the_category();
$separator = '&nbsp;&rsaquo;&nbsp;';
$output = '';
if($categories){
foreach($categories as $category) {
$output .= '<a href="'.get_category_link( $category->term_id ).'" title="' . esc_attr( sprintf( __( "View all posts in %s" ), $category->name ) ) . '">'.$category->cat_name.'</a>'.$separator;
}
echo trim($output, $separator);
}
echo '</div>';
echo '</div>';
endwhile;
}
wp_reset_postdata();
}
genesis();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.