Skip to content

Instantly share code, notes, and snippets.

View ramseyp's full-sized avatar

Pat Ramsey ramseyp

View GitHub Profile
@ramseyp
ramseyp / genesis_category_name.php
Created December 22, 2012 03:02
Place the name of the category before the archive content in a Genesis Child Theme.
add_action ( 'genesis_before_content','my_category_title' );
function my_category_title() {
if ( is_category() ) {
$term = get_category(get_query_var('cat'),false);
$name = $term->name;
echo '<h1 class="entry-title">'. $name .'</h1>';
}
}
@ramseyp
ramseyp / if_jwplayer_exists.php
Created December 17, 2012 19:47
Quick & Dirty gist to test for the existence of the JWPlayer plugin in a theme. Use if ( function_exists('function-to-test-for') ) and look for the existence of "jwplayer_init".
if ( function_exists('jwplayer_init') ) {
echo '<div class="vid">'. jwplayer_tag_callback( $pgmeta['_cwk_paperless_sub'][0] ) .'</div>';
} else {
echo '<div class="vid">'. $pgmeta['_cwk_paperless_sub'][0] .'</div>';
}
@ramseyp
ramseyp / minimum-page-title-mod.php
Created December 14, 2012 00:22
Inserting an exception into the conditionals for the page-title.php file in StudioPress's Minimum child theme
<?php
/**
*
* Modified page-title.php file for the Minimum child theme.
*
*/
if ( is_home() ) {
echo '<div id="page-title"><div class="wrap"><p>' . esc_html( get_bloginfo( 'description' ) ) . '<a class="page-title-button" href="#">' . __( 'Subscribe Now', 'minimum' ) . '</a></p></div></div>';
}
@ramseyp
ramseyp / add_action_example.php
Created December 12, 2012 06:31
Example of adding a div above the header in Genesis
<?php
/**
* Example of adding a div above the header in Genesis
*
*/
add_action( 'genesis_before_header','my_new_div' );
function my_new_div() {
echo '<div class="my-class-name"><p>My new div content.</p></div>';
@ramseyp
ramseyp / page_template_column.php
Created December 11, 2012 03:04
Add a page template column to WordPress's Pages view.
<?php
/**
*
* Add page template column to page listing. Make the Template column sortable
* http://www.codehooligans.com/2011/07/13/adding-custom-columns-to-wordpress-post-listing/
* http://justintadlock.com/archives/2011/06/27/custom-columns-for-custom-post-types/
*
*/
@ramseyp
ramseyp / tax_descript.php
Created November 29, 2012 21:36
Show the Description for the current taxonomy in a Genesis archive template.
<?php
/**
*
* Place this in archive.php. It will output the Description of the current-queried taxonomy above the listing of all posts in that taxonomy term.
*
*/
add_action( 'genesis_before_loop','s25_tax_description' );
function s25_tax_description() {
echo '<div class="taxonomy-description">'. term_description() .'</div>';
@ramseyp
ramseyp / whichlayout.php
Created November 29, 2012 21:30
Set the Genesis layout in a template
<?php
/**
* Different layouts include:
* __genesis_return_content_sidebar
* __genesis_return_sidebar_content
* __genesis_return_content_sidebar_sidebar
* __genesis_return_sidebar_sidebar_content
* __genesis_return_sidebar_content_sidebar
* __genesis_return_full_width_content
@ramseyp
ramseyp / wp-inf-scroll.php
Created November 15, 2012 02:59
add theme support for Infinite Scroll
<?php
/**
*
* Add support for Infinite Scroll
* container is the element containing your posts
* Full list of options at http://jetpack.me/support/infinite-scroll/
*
*/
add_theme_support( 'infinite-scroll', array(
@ramseyp
ramseyp / wp-disable-feeds.php
Created November 14, 2012 21:33
Disable Feeds for WordPress site
<?php
/**
*
* Disable feeds
*/
function fb_disable_feed() {
wp_die( __('No feed available,please visit our <a href="'. get_bloginfo('url') .'">homepage</a>!') );
}
@ramseyp
ramseyp / hide-editor.php
Created November 12, 2012 15:48
Hide the content editor for certain pages in WordPress
<?php
/**
* Hide editor on specific pages.
*
*/
add_action( 'admin_init', 'hide_editor' );
function hide_editor() {
// Get the Post ID.