[Resolved] oEmbed Filter?
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!
// 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;
Are you attempting to embed from one of the “approved” sites?
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.
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.
I solved by just using a simple
<?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_pagefor (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.
Just for anyone else looking.
I ended up storing the URL as a custom field then using wp_oembed_get
- The topic ‘[Resolved] oEmbed Filter?’ is closed to new replies.