ianatkins
Member
Posted 1 year 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;
ianatkins
Member
Posted 1 year 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.
Laurent LaSalle
Member
Posted 1 year ago #
Similar problem here. What the hell?!
ianatkins
Member
Posted 1 year ago #
Yeah I didn't find a solution.
bump.
bfred.it
Member
Posted 1 year 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);
?>
dan.imbrogno
Member
Posted 1 year 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.
bfred.it
Member
Posted 1 year 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.
ianatkins
Member
Posted 1 year 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