[wp-trac] [WordPress Trac] #19814: add_theme_support() inside init hook function breaks post attachments
WordPress Trac
wp-trac at lists.automattic.com
Thu Jan 12 17:47:12 UTC 2012
#19814: add_theme_support() inside init hook function breaks post attachments
---------------------------+-----------------------------
Reporter: jamesmehorter | Owner: James Mehorter
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Media | Version: 3.3.1
Severity: normal | Keywords: needs-patch
---------------------------+-----------------------------
When adding post-thumbnail support to a theme via add_theme_support(),
inside of an init hook function, the post media attachments no longer
work. Simply placing the add_theme_support() call outside of the init hook
function corrects this. See attached screenshots for display of the issue.
{{{
<?php
//WORKS - The 'Add Media' panel works as expected
//Initiate our theme setup
add_action( 'init', 'baltimore_theme_setup' );
//Adding thumbnail image support to our 'Form' custom post type
add_theme_support('post-thumbnails');
set_post_thumbnail_size( 150, 194, true ); // Normal post
thumbnails
function baltimore_theme_setup() {
// This theme styles the visual editor with editor-
style.css to match the theme style.
add_editor_style();
// This theme uses wp_nav_menu() in one location.
register_nav_menu( 'primary', __( 'Primary Menu',
'baltimore' ) );
//Create the 'form-page' post type
register_post_type('form-page', 'supports' =>
array('thumbnail');
//Create the 'type' taxonomy for the 'form-page' post type
register_taxonomy('form-page-type', 'form-page');
}//end baltimore_setup
//-------------------------------------------------
//DOES NOT WORK - Breaks the 'Add Media' panel
//DETAILS: The 'Add Media' panel for the post type 'form-page'
opens, and allows you to upload media, but the uploaded media is not
attached to the post. You can upload a media item, but it halts at
'Crunching'. Going into the Media > Library does show the media item, but
it's not attached to the post. Similarly, going into the post after
uploaded, and going into the Gallery tab of 'Add Media', shows no media
items.
//Initiate our theme setup
add_action( 'init', 'baltimore_theme_setup' );
function baltimore_theme_setup() {
//Adding thumbnail image support to our 'Form' custom post
type
add_theme_support('post-thumbnails');
set_post_thumbnail_size( 150, 194, true ); // Normal post
thumbnails
// This theme styles the visual editor with editor-
style.css to match the theme style.
add_editor_style();
// This theme uses wp_nav_menu() in one location.
register_nav_menu( 'primary', __( 'Primary Menu',
'baltimore' ) );
//Create the 'form-page' post type
register_post_type('form-page', 'supports' =>
array('thumbnail');
//Create the 'type' taxonomy for the 'form-page' post type
register_taxonomy('form-page-type', 'form-page');
}//end baltimore_setup
?>
}}}
--
Ticket URL: <http://core.trac.wordpress.org/ticket/19814>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list