• Resolved ianatkins

    (@ianatkins)


    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;
Viewing 8 replies - 1 through 8 (of 8 total)
  • Moderator James Huff

    (@macmanx)

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

    https://codex.www.ads-software.com/Embeds#Okay.2C_So_What_Sites_Can_I_Embed_From.3F

    Thread Starter ianatkins

    (@ianatkins)

    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.

    Similar problem here. What the hell?!

    Thread Starter ianatkins

    (@ianatkins)

    Yeah I didn’t find a solution.

    bump.

    Anonymous User 7341632

    (@anonymized-7341632)

    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);
    ?>

    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.

    Anonymous User 7341632

    (@anonymized-7341632)

    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.

    Thread Starter ianatkins

    (@ianatkins)

    Just for anyone else looking.

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

    https://codex.www.ads-software.com/Function_Reference/wp_oembed_get

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘oEmbed Filter?’ is closed to new replies.