This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://wpsnipp.com/index.php/functions-php/add-select-menu-to-filter-by-custom-field-in-admin/ | |
add_filter( 'parse_query', 'ba_admin_posts_filter' ); | |
add_action( 'restrict_manage_posts', 'ba_admin_posts_filter_restrict_manage_posts' ); | |
function ba_admin_posts_filter( $query ) | |
{ | |
global $pagenow; | |
if ( is_admin() && $pagenow=='edit.php' && isset($_GET['ADMIN_FILTER_FIELD_NAME']) && $_GET['ADMIN_FILTER_FIELD_NAME'] != '') { | |
$query->query_vars['meta_key'] = $_GET['ADMIN_FILTER_FIELD_NAME']; | |
if (isset($_GET['ADMIN_FILTER_FIELD_VALUE']) && $_GET['ADMIN_FILTER_FIELD_VALUE'] != '') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://wpsnipp.com/index.php/calendar/unregister-default-widgets/ | |
// unregister all default WP Widgets | |
function unregister_default_wp_widgets() { | |
unregister_widget('WP_Widget_Pages'); | |
unregister_widget('WP_Widget_Calendar'); | |
unregister_widget('WP_Widget_Archives'); | |
unregister_widget('WP_Widget_Links'); | |
unregister_widget('WP_Widget_Meta'); | |
unregister_widget('WP_Widget_Search'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://wpsnipp.com/index.php/functions-php/filter-search-results-by-post-type/ | |
function search_posts_filter( $query ){ | |
if ($query->is_search){ | |
$query->set('post_type',array('post','custom_post_type1', 'custom_post_type2')); | |
} | |
return $query; | |
} | |
add_filter('pre_get_posts','search_posts_filter'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://wpsnipp.com/index.php/posts/search-a-specific-post-type/ | |
function SearchFilter($query) { | |
if ($query->is_search) { | |
// Insert the specific post type you want to search | |
$query->set('post_type', 'feeds'); | |
} | |
return $query; | |
} | |
// This filter will jump into the loop and arrange our results before they're returned |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://wpsnipp.com/index.php/functions-php/attach-images-with-simple-thumbnail-selection-metabox/ | |
add_action("admin_init", "images_init"); | |
add_action('save_post', 'save_images_link'); | |
function images_init(){ | |
$post_types = get_post_types(); | |
foreach ( $post_types as $post_type ) { | |
add_meta_box("my-images", "Pictures", "images_link", $post_type, "normal", "low"); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form role="search" method="get" id="searchform" action="<?php bloginfo('siteurl'); ?>"> | |
<div> | |
<label class="screen-reader-text" for="s">Search for:</label> | |
<input type="text" value="" name="s" id="s" /> | |
in <?php wp_dropdown_categories( 'show_option_all=All Categories' ); ?> | |
<input type="submit" id="searchsubmit" value="Search" /> | |
</div> | |
</form> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://wpsnipp.com/index.php/functions-php/add-youtube-thumbnail-posts-with-custom-metabox/ | |
add_action("admin_init", "youtube_init"); | |
add_action('save_post', 'save_youtube_link'); | |
function youtube_init(){ | |
add_meta_box("youtube", "Youtube thumbnail code", "youtube_link", "post", "normal", "high"); | |
} | |
function youtube_link(){ | |
global $post; | |
$custom = get_post_custom($post->ID); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://wpsnipp.com/index.php/functions-php/highlight-post_states-within-admin-posts-and-pages/ | |
function custom_post_states( $post_states ) { | |
foreach ( $post_states as &$state ){ | |
$state = '<span class="'.strtolower( $state ).' states">' . str_replace( ' ', '-', $state ) . '</span>'; | |
} | |
return $post_states; | |
} | |
add_filter( 'display_post_states', 'custom_post_states' ); | |
function custom_post_states_css(){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://wpsnipp.com/index.php/functions-php/update-create-custom-post-status-mesasges-in-admin/ | |
// for layout fixes: http://pastebin.com/zNHEZMKR | |
add_filter( 'display_post_states', 'custom_post_state' ); | |
function custom_post_state( $states ) { | |
global $post; | |
$show_custom_state = get_post_meta( $post->ID, '_status' ); | |
// We are using "None" as a way to disable this feature for the current post. | |
if ( $show_custom_state && $show_custom_state[0] != 'None' ) $states[] = '<span class="custom_state ' . strtolower( $show_custom_state[0] ) . '">' . $show_custom_state[0] . '</span>'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Prevent direct file access to functions.php | |
if (!empty($_SERVER['SCRIPT_FILENAME']) && 'functions.php' == basename($_SERVER['SCRIPT_FILENAME'])) | |
{ | |
die ('No access!'); | |
} |