Skip to content

Instantly share code, notes, and snippets.

Pat Ramsey ramseyp

Block or report user

Report or block ramseyp

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ramseyp
ramseyp / 0_reuse_code.js
Created Dec 19, 2013
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@ramseyp
ramseyp / no_update_plugin.php
Created Nov 14, 2013
Simple code useful if you don't want a WordPress plugin to show an update notice.
View no_update_plugin.php
<?php
/**
* Keep your plugin from updating
* http://markjaquith.wordpress.com/2009/12/14/excluding-your-plugin-or-theme-from-update-checks/
*/
function s25_plugin_no_update( $r, $url ) {
if ( 0 !== strpos( $url, 'http://api.wordpress.org/plugins/update-check' ) )
return $r; // Not a plugin update request. Bail immediately.
$plugins = unserialize( $r['body']['plugins'] );
unset( $plugins->plugins[ plugin_basename( __FILE__ ) ] );
@ramseyp
ramseyp / no_update_theme.php
Created Nov 14, 2013
Useful code if you don't want your WordPress them to show an update notice.
View no_update_theme.php
<?php
/**
* Keep your theme from updating
* http://markjaquith.wordpress.com/2009/12/14/excluding-your-plugin-or-theme-from-update-checks/
*/
function s25_no_update_theme( $r, $url ) {
if ( 0 !== strpos( $url, 'http://api.wordpress.org/themes/update-check' ) )
return $r; // Not a theme update request. Bail immediately.
$themes = unserialize( $r['body']['themes'] );
unset( $themes[ get_option( 'template' ) ] );
@ramseyp
ramseyp / hide_editor.php
Created Oct 28, 2013
Hide the WordPress editor on specific pages. This example looks for a page's name or a page template. The code goes in your functions.php file.
View hide_editor.php
<?php
// Hide Editor on Select Pages
function s25_hide_editor() {
// Get the Post ID.
$post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID'] ;
if( !isset( $post_id ) ) return;
// Hide the editor on the page titled 'Homepage'
$homepgname = get_the_title($post_id);
@ramseyp
ramseyp / filter_yoast_seo.php
Created Oct 10, 2013
Filter Yoast Meta Box Priority - returning low moves it below standard meta boxes
View filter_yoast_seo.php
<?php
// Filter Yoast Meta Priority
function move_yoast_seo_box() {
if ( defined( 'WPSEO_VERSION' ) ) :
add_filter( 'wpseo_metabox_prio', function() { return 'low'; } );
endif;
}
add_action('admin_init', 'move_yoast_seo_box');
@ramseyp
ramseyp / cmb_page_id.php
Last active Dec 21, 2015
If you use this custom meta box code: https://github.com/WebDevStudios/Custom-Metaboxes-and-Fields-for-WordPress then this gist may be useful. It allows you to use the page slug as a "show-on" filter.
View cmb_page_id.php
<?php
/**
* Use the page slug to filter the 'show-on' of a meta box
* @author Pat Ramsey
* @link https://gist.github.com/ramseyp/6227383
*
* @param bool $display
* @param array $meta_box
* @return bool display metabox
*/
@ramseyp
ramseyp / wp_show_custom_meta.php
Last active Dec 20, 2015
Returns first value of WordPress custom field. Runs it though wpautop() if desired. Has option for you to insert text / html before and after the value, allowing you to wrap the value with content.
View wp_show_custom_meta.php
<?php
/**
* Displays the content of a custom field, along with wrapping code or content.
* @param string $key name, or key, of the custom field.
* @param string $before what should be shown directly before the custom field value.
* @param string $after what is output directly after the custom field value.
* @param boolean $wpautop filters the value through wpautop().
* @return string first value of the custom field, prepended by $before, followed by $after.
*/
@ramseyp
ramseyp / base-slider.php
Created Jul 17, 2013
Basic carousel / slider code using flexslider.
View base-slider.php
<?php
/**
* Basic slider. Uses flexslider.js, theme options framework, a custom post type and custom meta boxes.
*
* @author Pat Ramsey
* @link http://slash25.com
*/
add_image_size( 'slider', 920, 286, true ); // we want a new image size for the slider background
@ramseyp
ramseyp / lastname-firstname-user-sort.php
Created Jun 28, 2013
Sorted the return of a Wp_User_Query by both the last name value and the first name value. This way, if multiple users have the same last name, those particular users are then sorted by first name.
View lastname-firstname-user-sort.php
<?php
function s25_member_loop() {
$args = array(
'role' => 'member', // the role we're targeting
'exclude' => '1', // exclude admin
'fields' => 'all_with_meta',
'meta_key' => 'last_name', //query on the last_name key
'meta_key' => 'first_name', // also the first_name key
);
$membersquery = new WP_User_Query( $args );
@ramseyp
ramseyp / show_testimonials.php
Last active Dec 17, 2015
Grab a custom post type of testimonial & output it, along with a custom field for the person's credentials / title
View show_testimonials.php
<?php
$testimeta = get_post_custom($testimq->post->ID);
if ( $testimeta['s25_testim_cred'][0] !='' ) { $cred = ', '. $testimeta['s25_testim_cred'][0]; } else { $cred = ''; }
echo '<div class="entry-content">'. wpautop( get_the_content($testimq->post->ID), true ) .'</div>';
echo '<p class="attrib"><em>&ndash; '. get_the_title($testimq->post->ID) . $cred .'</em></p>';
echo '</div>';
}
You can’t perform that action at this time.