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
//Drafts Dashboard Widget For Custom Post Type | |
function project_drafts(){ | |
$posts_query = new WP_Query( array( | |
// Leave this as "post" if you just want blog posts | |
'post_type' => 'projects', | |
'post_status' => 'draft', | |
'posts_per_page' => 5, | |
'orderby' => 'date', | |
'order' => 'DESC' | |
) ); |
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
//Custom Login Page | |
function custom_login() { | |
echo '<link rel="stylesheet" type="text/css" href="'.get_bloginfo('template_directory').'/custom-login/custom-login.css" />'; | |
} | |
add_action('login_head', 'custom_login'); |
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
//Add Custom Dashboard Widget - Side | |
add_action( 'wp_dashboard_setup', 'my_dashboard_setup_function' ); | |
function my_dashboard_setup_function() { | |
add_meta_box( 'my_dashboard_widget', 'Electrico Useful Information', 'my_dashboard_widget_function', 'dashboard', 'side', 'high' ); | |
} | |
function my_dashboard_widget_function() { | |
// widget content goes here | |
echo '<p>Some Content</p>'; | |
} |
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
//////////////////////////////////////////////// | |
//Add Project Type Column to Projects Backend | |
/////////////////////////////////////////////// | |
add_filter('manage_edit-project_columns', 'project_columns'); | |
function project_columns($columns) { | |
unset($columns['date']); | |
$columns['Type'] = 'Type'; | |
$columns['date'] = 'Date'; | |
return $columns; | |
} |
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
//Custom Additional Excerpt Length | |
function custom_excerpt($content_length = 250, $allowtags = true, $allowedtags = '') { | |
global $post; | |
$exc = $post->post_excerpt; | |
if ($exc == '') { | |
$content = $post->post_content; | |
} else { | |
$content = $post->post_excerpt; | |
} | |
$content = apply_filters('the_content', $content); |
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
//Change Title By Post Type | |
function custom_title_text( $title ){ | |
$screen = get_current_screen(); | |
if ( 'issues' == $screen->post_type ) { | |
$title = 'Issue Months and Year e.g. "Jul/Aug 2011"'; | |
} | |
return $title; | |
} | |
add_filter( 'enter_title_here', 'custom_title_text' ); |
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
//Change Excerpt Length | |
function new_excerpt_length($length) { | |
return 20; | |
} | |
add_filter('excerpt_length', 'new_excerpt_length'); |
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
// | |
function the_post_thumbnail_caption() { | |
global $post; | |
$thumbnail_id = get_post_thumbnail_id($post->ID); | |
$thumbnail_image = get_posts(array('p' => $thumbnail_id, 'post_type' => 'attachment')); | |
if ($thumbnail_image && isset($thumbnail_image[0])) { | |
echo '<span>'.$thumbnail_image[0]->post_excerpt.'</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
//Add Alert Notice To Options Pages | |
add_action( 'admin_notices', 'my_admin_notice' ); | |
function my_admin_notice(){ | |
global $current_screen;</div> | |
if ( $current_screen->parent_base == 'options-general' ) | |
echo '<div><p>Warning - changing settings on these pages may cause problems with your website’s design!</p></div>'; | |
} |