Skip to content

Instantly share code, notes, and snippets.

@shaynesanderson-zz
shaynesanderson-zz / user-meta.php
Last active December 17, 2015 07:29
Add meta box to user profile
<?php
// Add custom meta to user profile screen
add_action( 'show_user_profile', 'example_show_extra_profile_fields' );
add_action( 'edit_user_profile', 'example_show_extra_profile_fields' );
function example_show_extra_profile_fields( $user ) { ?>
<h3>Payment information</h3>
@shaynesanderson-zz
shaynesanderson-zz / search-post-type.php
Created May 14, 2013 01:26
Search results by Post Type
<?php
function SearchFilter($query) {
if ($query->is_search) {
$query->set('post_type', 'post');
}
return $query;
}
add_filter('pre_get_posts','SearchFilter');
@shaynesanderson-zz
shaynesanderson-zz / reposition-footer.php
Created May 14, 2013 01:25
Genesis reposition footer
@shaynesanderson-zz
shaynesanderson-zz / custom-header.php
Created May 14, 2013 01:23
Genesis custom header
<?php
remove_action('genesis_header', 'genesis_do_header');
add_action('genesis_header', 'custom_header');
function custom_header() {
?>
<div id="logo">
<a href="<?php echo get_bloginfo('url'); ?>"><img src="<?php echo CHILD_URL.'/images/logo.png'; ?>" width="250" height="290" alt="" /></a>
</div>
<div id="header-right">
@shaynesanderson-zz
shaynesanderson-zz / cpt-dropdown.php
Created May 14, 2013 01:22
CPT dropdown meta in another CPT
<?php
add_action( 'cmb_render_location_list', 'dss_cmb_render_location_list', 10, 2 );
function dss_cmb_render_location_list( $field, $meta ) {
global $post;
$tmp_post = $post;
// set the args
$args = array (
'post_type' => 'locations',
'posts_per_page' => -1,
<?php
function ss_php_memory_check() {
echo '<!-- PHP Memory Limit: ' . ini_get( 'memory_limit' ) . ' -->';
}
add_action( 'wp_footer', 'ss_php_memory_check', 20 );
@shaynesanderson-zz
shaynesanderson-zz / add-content.php
Created May 14, 2013 01:19
Add content above Genesis content
<?php
add_filter ( 'genesis_before_content_sidebar_wrap', 'example_custom_header' );
function example_custom_header () {
echo '<div id="page_featured">';
echo the_post_thumbnail( 'featured-page' );
echo '</div>';
}
@shaynesanderson-zz
shaynesanderson-zz / first-menu.php
Created May 14, 2013 01:18
Add class to first menu item
<?php
function nav_menu_first_last( $items ) {
$position = strrpos($items, 'class="menu-item', -1);
$items=substr_replace($items, 'menu-item-last ', $position+7, 0);
$position = strpos($items, 'class="menu-item');
$items=substr_replace($items, 'menu-item-first ', $position+7, 0);
return $items;
}
add_filter( 'wp_nav_menu_items', 'nav_menu_first_last' );
@shaynesanderson-zz
shaynesanderson-zz / featured-image-1.php
Last active December 17, 2015 03:39
Make featured image first in WP Gallery, no matter what order it's set in.
@shaynesanderson-zz
shaynesanderson-zz / bp-custom.php
Created May 6, 2013 22:11
Lock BuddyPress to only logged in users
<?php
// **** Privacy ********
function restrict_access(){
global $bp, $bp_unfiltered_uri;
// If user is not logged in and
if (!is_user_logged_in() &&
(
// The current page is not register or activation