#12745 closed defect (bug) (fixed)
Call to undefined function get_post_thumbnail_id()
Reported by: | dphiffer | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.0.1 |
Component: | General | Keywords: | reporter-feedback |
Focuses: | Cc: |
Description
Hope this isn't a duplicate, but post thumbnails seem to be broken in the current trunk revision (13871). If I upload an image on a post I get:
Fatal error: Call to undefined function get_post_thumbnail_id() in /path/to/wp-admin/includes/media.php on line 1284
Change History (13)
#3
@
15 years ago
- Cc aaron@… added
- Keywords reporter-feedback added
also can't reproduce, works for me on php 5.2.9. can you provide some more information on your setup such as php version. Is it only when uploading images through the post thumbnail selector or through the regular media uploader as well?
#4
@
15 years ago
get_post_thumbnail_id() is in a file (post-thumbnail-template.php) that is conditionally loaded, assuming the theme supports thumbnails. This requires add_theme_support('post-thumbnails')
to be called on the after_setup_theme hook (or no hook), not init, which is too late for require_if_theme_supports().
Thus, whenever we call one of those functions, we first have to check for current_theme_supports. We do that on line 1284.
It's kind of confusing, and not entirely necessary to conditionally load these functions (we could simply have done if ( ! current_theme_supports('post-thumbnails') ) return false;
) but it was designed with forward-thinking and scalability in mind.
#5
@
15 years ago
This definitely causes confusion:
http://wordpress.org/support/topic/355685
http://www.google.com/search?q=get_post_thumbnail_id
The other issue of course is removing support for thumbnails from a theme (i.e. from a child theme) will blow up the theme any time one of the post thumbnail template functions are used.
I'm questioning thus wrapping add_theme_support('post-thumbnails') in a function in twentyten that could be overridden in a child theme. If you wanted to *remove* thumbnail support, good portions of twentyten would generate fatal errors.
#6
@
15 years ago
- Resolution set to invalid
- Status changed from new to closed
Thanks nacin, et al. I was calling this within my 'init' hook.
#9
@
14 years ago
- Resolution invalid deleted
- Status changed from closed to reopened
- Type changed from defect (bug) to task (blessed)
- Version set to 3.0.1
if I search on wordpress.org for the hook I can not find a documentation of that.
So the documentation on wordpress.org should contain that hint in which hook the theme support for post_thumbnails should be added.
#10
@
14 years ago
- Resolution set to fixed
- Status changed from reopened to closed
- Type changed from task (blessed) to defect (bug)
Can't reproduce, worksforme.