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 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 Post Type To Category Archives | |
| add_filter('pre_get_posts', 'query_post_type'); | |
| function query_post_type($query) { | |
| if(is_category() || is_tag()) { | |
| $post_type = get_query_var('post_type'); | |
| if($post_type) | |
| $post_type = $post_type; | |
| else | |
| $post_type = array('nav_menu_item','post','private_post'); // replace private_post to your custom post type, Leave nav_menu_item where it is! | |
| $query->set('post_type',$post_type); |
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 Post Thumbnail to Feed | |
| function feedFilter($query) { | |
| if ($query->is_feed) { | |
| add_filter('the_content', 'feedContentFilter'); | |
| } | |
| return $query; | |
| } | |
| add_filter('pre_get_posts','feedFilter'); | |
| function feedContentFilter($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_theme_support('post-thumbnails'); | |
| set_post_thumbnail_size( 150, 120, true ); // Normal post thumbnails | |
| add_image_size( 'magazine-post-thumbnail', 260, 174, true ); // Permalink thumbnail size | |
| add_image_size( 'home-post-thumbnail', 168, 89, true ); // Permalink thumbnail size | |
| add_image_size( 'single-post-thumbnail', 527, 317, true ); // Permalink thumbnail size |
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
| /** | |
| Made with the help of a tutorial at WPShout.com => http://wpshout.com. | |
| Courtesy of the Hybrid theme - themehybrid.com | |
| * Adds the Hybrid Settings meta box on the Write Post/Page screeens | |
| * | |
| * @package Hybrid | |
| * @subpackage Admin | |
| */ |
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 Instructions to Featured Image Box | |
| add_filter( 'admin_post_thumbnail_html', 'add_featured_image_html'); | |
| function add_featured_image_html( $html ) { | |
| return $html .= '<p>This is some sample text that can be displayed within the feature image box.</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 Custom Post Type To Feed | |
| function mysite_feed_request($vars) { | |
| if (isset($vars['feed']) && !isset($vars['post_type'])) | |
| $vars['post_type'] = array('post', 'projects'); | |
| return $vars; | |
| } | |
| add_filter('request', 'mysite_feed_request'); |
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 Backend Column from Custom Field. Be sure to edit post-type- "manage_edit-POSTTYPE_columns"- and Custom Field Name. | |
| /////////////////////////////////////////////////////////// | |
| add_filter('manage_edit-staff_columns', 'my_columns'); | |
| function my_columns($columns) { | |
| unset($columns['author']); | |
| unset($columns['date']); | |
| $columns['Name'] = 'Name'; | |
| $columns['author'] = 'Author'; | |
| $columns['date'] = 'Date'; |
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 category nicenames in body and post class | |
| function category_id_class($classes) { | |
| global $post; | |
| foreach((get_the_category($post->ID)) as $category) | |
| $classes[] = $category->category_nicename; | |
| return $classes; | |
| } | |
| add_filter('post_class', 'category_id_class'); | |
| add_filter('body_class', 'category_id_class'); |