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 Single Post Templating By Category | |
| add_filter('single_template', create_function('$t', 'foreach( (array) get_the_category() as $cat ) { if ( file_exists(TEMPLATEPATH . "/single-{$cat->term_id}.php") ) return TEMPLATEPATH . "/single-{$cat->term_id}.php"; } return $t;' )); |
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 Field and Value to all pages | |
| add_action('publish_page', 'add_custom_field_automatically'); | |
| function add_custom_field_automatically($post_ID) { | |
| global $wpdb; | |
| if(!wp_is_post_revision($post_ID)) { | |
| add_post_meta($post_ID, 'ngg_gal_Images', '42', true); | |
| } | |
| } |
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>'; | |
| } |
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
| //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
| //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
| //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
| //////////////////////////////////////////////// | |
| //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
| //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>'; | |
| } |