Youtube auto embed when html is enabled :)
Today i am gona share the codes/tutorial - how to embed youtube videos with or with out HTML enable on classipress.
This post specially for @ Spymare mate
------------------------------------------------
Without HTML:
Its much easy
.. just make sure you turn on "Auto embed" at your wordpress admin settings->media
and then.. classipress->settings->go to listing tab -> and make sure HTML turned off
Now.. just copy/paste youtube url during ad posting on "ad description" your youtube video will show up automatically.
You can control the width and height from wordpress settings->media
its easy yah
With HTML:
[CENTER]
ALWAYS BACK UP [/CENTER]
1. make a custom field from classipress settings,
2. remember your custom fields meta name something like - cp_youtube_video
3. open your functions.php file
4.
/**
* add any of your custom functions below this section
*/
under this line add bellow codes -
PHP Code:
function embed_youtube( $url = '' ) {
if( is_single() ) {
if( $url == '' ) {
return;
}
$parse = parse_url( $url );
if( $parse ) {
parse_str( $parse['query'], $video );
if( $video['v'] ) {
?>
<iframe width="560" height="349" src="http://www.youtube.com/embed/<?php echo $video['v']; ?>" frameborder="0" allowfullscreen></iframe>
<?php
}
}
}
}
function youtube_embed_content() {
global $post;
$video = get_post_meta( $post->ID, 'cp_youtube_video', true );
embed_youtube( $video );
}
add_action( 'appthemes_after_post_content', 'youtube_embed_content' );
?>
replace -
cp_youtube_video meta name with your's one.
5. Save the functions.php file ,
6. make sure that custom field is enable on ad submit form
7. Thats all
Enjoy... and dont forget to say thanks
* This tuto also posted on our site -
embed youtube video on classipress | Melbweb || Australian Web Solution Service Provider