-
Notifications
You must be signed in to change notification settings - Fork 149
twentysixteen_content_width action breaks oEmbed for Custom Post Types #464
Comments
Sorry, I was not able to replicate the issue. I tested it with WP 4.4 and 4.5 and used your code. |
I just tested again on a fresh new local install. The CPT didn't render as an oEmbed at all until I added the conditional before the GLOBAL. |
It also seems only logical that since it's being defined by a GLOBAL that it should first check whether that Global already exists, right? |
Thanks Evan for the confirmation. Make sure to clear the _oembed cache in wp_postmeta to make sure you're getting the freshest results when you test. Since this seems to affect a Core theme, and the results are varying so much (with and without the conditional -- for some and not for others), it might be worth creating a Trac ticket on this. |
Testing this locally I can reproduce the issue. The provided solution also fixes the issue. |
We need a PR to test this ideally in a variety of circumstances. |
WordPress 4.5 supports CPT templates for oEmbed now, for example embed-promotion.php. But the embed defaults reference $GLOBALS['content_width'] -- here -- in the same way that Twenty Sixteen does -- here.
This somehow negatively impacts only native CPT embeds. Here's a screenshot:
STEPS TO REPRODUCE
FIX
Adding
if ( ! empty( $GLOBALS['content_width'] ) )
directly before that line in thetwentysixteen_content_width()
function prevents such problems.CAVEAT
This didn't seem to affect all CPTs and it's not clear to me why exactly, but here's the code I used for the CPT that broke because of this function:
The text was updated successfully, but these errors were encountered: