WordPress.org

Forums

[resolved] oEmbed Filter? (9 posts)

  1. ianatkins
    Member
    Posted 5 years ago #

    When getting some content with the get_page function I can't make an oEmbed video work. The template just returns the flat link to the file.

    Here is my code, I've tried apply the the_content filter but its not working.

    Any ideas / help!

    Thanks

    Ian.

    // load videos
    	$page_id = 724;
    	$page_data = get_page( $page_id );
    	$videos = $page_data->post_content; // Get Content
    	$videos = apply_filters('the_content', $videos);
    	echo $videos;
  2. James Huff
    Volunteer Moderator
    Posted 5 years ago #

    Are you attempting to embed from one of the "approved" sites?

    http://codex.wordpress.org/Embeds#Okay.2C_So_What_Sites_Can_I_Embed_From.3F

  3. ianatkins
    Member
    Posted 5 years ago #

    Yep, its youtube. it just doesn't get processed.

    If I post the url in a normal page it processes fine. Its just accessing the data via get_page that doesn't work.

  4. Laurent LaSalle
    Member
    Posted 4 years ago #

    Similar problem here. What the hell?!

  5. ianatkins
    Member
    Posted 4 years ago #

    Yeah I didn't find a solution.

    bump.

  6. bfred.it
    Member
    Posted 4 years ago #

    Same issue, but it only appears in a category archive. It's not caused by a conflict since I get the non-embedded url even if this is the only thing I include in the page:

    <?php
    $player = get_page($pageid = 93);
    echo apply_filters('the_content', $player->post_content);
    ?>
  7. dan.imbrogno
    Member
    Posted 4 years ago #

    One thing I'd recommend trying is wrapping your content in stripslashes(), or maybe increase the number that the filter gets applied, i.e.

    apply_filters('the_content', $videos, 99);

    Just blind guesses. Seeing a var_dump of your $videos variable may help though.

  8. bfred.it
    Member
    Posted 4 years ago #

    I solved by just using a simple query_posts

    <?php 	query_posts(array('page_id'=>93));
    if(have_posts()) : the_post(); ?>
    <aside>
    <h2><?php the_title(); ?></h2>
    <?php the_content(); ?>
    </aside>
    <?php
    wp_reset_query();
    endif;?>

    I was using this method earlier and I switched to get_page for (unproven) speed's sake, but apparently it doesn't work as well as query_posts. You could also use a WP_query object, but I'm not familiar with it.

  9. ianatkins
    Member
    Posted 4 years ago #

    Just for anyone else looking.

    I ended up storing the URL as a custom field then using wp_oembed_get

    http://codex.wordpress.org/Function_Reference/wp_oembed_get

Topic Closed

This topic has been closed to new replies.

About this Topic