• Resolved pdxchambers

    (@pdxchambers)


    I’m developing a custom theme that is supposed to display a YouTube video on front-page.php. The theme uses a custom loop to pull the most recent post with a specific category name and display it. The posts in this category just contain an embedded YouTube video which I’m embedding by simply entering the URL for the video in the post without any sort of formatting added. The weird part is the video displays properly in the post editor and in the single post view, but the front page template is just displaying the URL as text. I would suspect a problem with the template but my development box has not had this issue. I updated both my development box and the non-production server to WordPress 4.8 and the issue persisted. I found somewhere on the web that it might have to do with the https in the URL so I tried removing the ‘s’ with no change. My question is whether anyone else has run into this issue and if so what in the world is going on? Thanks!

Viewing 6 replies - 1 through 6 (of 6 total)
  • Hello,

    Is it a custom template by you or a pre-made one? Any errors in the console? Or if there’s a possibility for a link even.

    I understand the problem but it depends on how the whole theme and it’s outputs are built.

    Best regards,
    Konstantinos

    Thread Starter pdxchambers

    (@pdxchambers)

    It’s a template that I’m developing. It’s just weird because it works on my development machine but not on the test server even though it’s the same code. I’m not seeing anything obvious in the console and it works everywhere else in WordPress (post editor, single post view, etc)

    Moderator bcworkz

    (@bcworkz)

    It sounds like the oEmbed callback is not being called on your front page content. How are you displaying the post content? the_content()? That is where the oEmbed is normally hooked into. If you are using another method for display, pass the content through WP_Embed::autoembed() before output.

    Note that oEmbed has trouble matching some YouTube URLs, it skips over them. It’s usually embed URLs that include the iframe argument. If your links are always YouTube, instead of WP_Embed::autoembed(), use wp_embed_handler_youtube(). It tries to fix such URLs before calling WP_Embed::autoembed() itself.

    Another possibility is the server is running an old PHP version and the current oEmbed PHP isn’t working as it should. Maybe related to how regexp is interpreted more than any outright error.

    Thread Starter pdxchambers

    (@pdxchambers)

    I’m using the_content() in the custom loop. I tried upgrading the PHP on my hosting provider to 7.0 (from 5.6) but there wasn’t any change. It seems to me that if the issue was with the oEmbed hook it would be doing the same thing on the single post template, but that template is displaying the video as expected.

    Moderator bcworkz

    (@bcworkz)

    Yes, you are correct, it should be consistent across templates. When something like that occurs, I would suspect some unintentional theme or plugin influence that is conditionally doing something through an action or filter and that condition is not fully implementing the proper logic to avoid undue influence.

    If you disable all plugins and switch to one of the twenty* themes, then make your template a custom page template, oEmbed should work normally on a page using your template. If not there would have to be something else on your template that is messing up oEmbed. Unlikely I should think, so when oEmbed works on your template in this state, incrementally restore your original configuration, testing along the way. When oEmbed breaks again, the last thing you enabled is the culprit.

    Thread Starter pdxchambers

    (@pdxchambers)

    Doh! WordPress troubleshooting 101… disable plugins… found the problem, something with the All-in-One Event Calendar by Time.ly plugin is interfering with oEmbed apparently. I disabled it and the problem was fixed.

    Thanks for the help!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Embedded Video Doesn’t Display’ is closed to new replies.