Customizr and The Event Calendar random images
-
Having resolved a problem with The Event Calendar in Customizr I thought I would share the result with the forum which has appeared in so many useful search results.
With thumbnails for single posts turned on apparently random images were appearing in Event Calendar pages. It turns out that
get_the_ID
was returning0
and consequentlytc_get_id_from_attachment
inclass-content-post_thumbnails.php
was returning an attachment to post0
. As zero seems to be the place holder for the parent id of unattached posts an unexpected image was being displayed.Presumably (I haven’t checked)
get_the_ID
returning0
rather thanfalse
is due to some Event Calendar weirdness, I stopped looking once I came up with the following fix:add_filter('tc_use_attachement_as_thumb', 'not_when_get_the_id_zero'); function not_when_get_the_id_zero( $bool ) { if ( get_the_ID() === 0 ) { return false; } return $bool; }
The odd spelling of “attachment” in the hook name is the way it appears in the customizr code.
I hope this helps someone else struggling with the same problem.
Apologies if this has already been covered, I have only performed a desultory search of this forum.
- The topic ‘Customizr and The Event Calendar random images’ is closed to new replies.