Skip to content

Instantly share code, notes, and snippets.

View davekuhar's full-sized avatar
🧑‍🚀

Dave Kuhar davekuhar

🧑‍🚀
  • 16:53 (UTC -04:00)
View GitHub Profile
@davekuhar
davekuhar / functions.php
Created June 26, 2012 15:39
Add function to enable conditional for eg. if (is_post_type('custom-post-type'))
function is_post_type($type){
global $wp_query;
if($type == get_post_type($wp_query->post->ID)) return true;
return false;
}
@davekuhar
davekuhar / functions.php
Created June 26, 2012 15:43
Change "Enter title here" Text in new WordPress post
add_filter( 'enter_title_here', 'ts_enter_title_here' );
function ts_enter_title_here( $title ){
$screen = get_current_screen();
if ( 'custom_post_type' == $screen->post_type ) {
$title = 'Custom Post Type Title Text';
}
return $title;
}
@davekuhar
davekuhar / functions.php
Created June 26, 2012 15:59
Add 'first' and 'last' to WP navigation
add_filter('wp_nav_menu', 'add_first_and_last');
function add_first_and_last($output) {
$output = preg_replace('/class="menu-item/', 'class="first-menu-item menu-item', $output, 1);
$output = substr_replace($output, 'class="last-menu-item menu-item', strripos($output, 'class="menu-item'), strlen('class="menu-item'));
return $output;
}
@davekuhar
davekuhar / functions.php
Created June 26, 2012 16:02
Add Genesis SEO and layout features to CPTs
add_post_type_support( 'CPTNAME', 'genesis-seo' );
add_post_type_support( 'CPTNAME', 'genesis-layouts' );
@davekuhar
davekuhar / functions.php
Created June 28, 2012 03:22
WordPress Pro-Panel setup for Genesis child themes
// Options Panel
require_once(CHILD_DIR . '/admin/admin-functions.php');
require_once(CHILD_DIR . '/admin/admin-interface.php');
require_once(CHILD_DIR . '/admin/theme-settings.php');
@davekuhar
davekuhar / functions.php
Created September 10, 2012 22:36
Detect mobile and serve up alternate content…
require_once( CHILD_DIR . '/lib/functions/mobile_detect.php' );
function xmit_cover_image_rotator() {
if (is_mobile()) {
echo '';
}
elseif (is_home()) {
echo '<div id="cover-image-rotator">';
echo '<div class="rotator-wrap">';
@davekuhar
davekuhar / functions.php
Created November 12, 2012 19:56
functions.php code to make Genesis themes compatible with LoopBuddy
<?php
add_theme_support('loop-standard');
if ( ! function_exists( 'dynamic_loop' ) ) {
function dynamic_loop() {
global $dynamic_loop_handlers;
if ( empty( $dynamic_loop_handlers ) || ! is_array( $dynamic_loop_handlers ) )
return false;
ksort( $dynamic_loop_handlers );
foreach ( (array) $dynamic_loop_handlers as $handlers ) {
foreach ( (array) $handlers as $function ) {
@davekuhar
davekuhar / viewport.php
Created August 20, 2013 17:28
Set viewport content width to accommodate layouts wider than 980px on non-responsive sites. In this example the .wrap was 1060px so the viewport width was set to 1080 which allowed for a 10px gutter. https://developer.apple.com/library/safari/documentation/AppleApplications/Reference/SafariWebContent/UsingtheViewport/UsingtheViewport.html#//appl…
/** Add Viewport meta tag for mobile browsers */
add_action( 'genesis_meta', 'storewithstyle_add_viewport_meta_tag' );
function storewithstyle_add_viewport_meta_tag() {
// echo '<meta name="viewport" content="width=device-width, initial-scale=1.0"/>';
echo '<meta name="viewport" content="width=1080" />';
}
@davekuhar
davekuhar / custom-css.php
Created August 20, 2013 22:13
Replaces style.css as default style sheet with genesis.css. Adds custom.css for child theme customizations.
add_action( 'wp_enqueue_scripts', 'custom_load_custom_style_sheet' );
function custom_load_custom_style_sheet() {
wp_enqueue_style( 'custom-stylesheet', CHILD_URL . '/css/custom.css', array(), CHILD_THEME_VERSION );
}
//* Replace default style sheet
add_filter( 'stylesheet_uri', 'custom_replace_default_style_sheet', 10, 2 );
function custom_replace_default_style_sheet() {
return CHILD_URL . '/css/genesis.css';
}
<?php
/*
replacing the default "Enter title here" placeholder text in the title input box
with something more descriptive can be helpful for custom post types
place this code in your theme's functions.php or relevant file
source: http://flashingcursor.com/wordpress/change-the-enter-title-here-text-in-wordpress-963
*/