WordPress.org

Ready to get started?Download WordPress

Forums

Video Thumbnails
[resolved] Scan whole post instead of "the_content" (8 posts)

  1. rouprasith
    Member
    Posted 1 year ago #

    Well, I've done some heavy coding on my wordpress blog and I've managed to place my YouTube embed code outside of "<?php the_content(); ?>".
    I've created a custom taxonomy to place the Youtube video id in the embed code using shortcodes for easier back-end use.

    My question, is there a way to scan outside of "<?php the_content(); ?>"?
    Is it possible to scan a div within the post? that way I can put the embed video inside a div and have the plugin scan that div on every post I make.

    I believe this is the code I need to modify scanning "the_content":

    $post_array = get_post( $post_id );
    $markup = $post_array->post_content;
    $markup = apply_filters( 'the_content', $markup );

    thanks for your help :D

    http://wordpress.org/extend/plugins/video-thumbnails/

  2. Sutherland Boswell
    Member
    Plugin Author

    Posted 1 year ago #

    Can you try to explain how you're embedding videos more clearly? Are you using a custom field containing the YouTube ID?

  3. rouprasith
    Member
    Posted 1 year ago #

    @Sutherland Boswell

    I'm not using a custom field, I'm using a custom post type.

    for examply:
    content-single-video.php
    I've placed the embed code before <?php the_content(); ?>
    my code looks like thiis:

    <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    
    <div class="section-header">
    		<h1 class="section-title"><?php the_title(); ?></h1>
    	</div>
    <iframe width="680" height="383" src="http://www.youtube.com/embed/<?php echo do_shortcode('[youtube][/youtube]'); ?>?rel=0&showinfo=0" frameborder="0" allowfullscreen></iframe>
    		<?php the_content(); ?>
    </article><!-- #post-<?php the_ID(); ?> -->

    "[youtube][/youtube]" is the shortcode I use to insert the id of the video.

  4. Sutherland Boswell
    Member
    Plugin Author

    Posted 1 year ago #

    How are you inserting the ID into the shortcode? It sounds like there may be a simpler way to code what you're trying to do.

  5. rouprasith
    Member
    Posted 1 year ago #

    @Sutherland Boswell

    to sum it all up, I made it to where i don't have to keep copying and pasting the embed code of the video. so it's already coded into the post outside of the content area. That isn't important, I just want to find a way to scan the entire post (maybe a div within the post) instead of scanning the content area of the post..

  6. Sutherland Boswell
    Member
    Plugin Author

    Posted 1 year ago #

    The plugin interacts with the data for each post using the database, not scanning the actual HTML end result of each template. So how are you saving the YouTube ID into the WordPress database?

  7. rouprasith
    Member
    Posted 1 year ago #

    @Sutherland Boswell

    Oh, That makes much more sense.
    I'm entering the YouTube ID alone into a Taxonomy I created called 'youtubecode' so I'm assuming I'd have to get the plugin to scan that table entry for the post?

  8. Sutherland Boswell
    Member
    Plugin Author

    Posted 1 year ago #

    In the settings of the plugin select your custom post type and set the custom field to 'youtubecode'.

    Since you're only storing the YouTube ID in that field, you'll have to modify the plugin to know it's for YouTube. Change this:

    if ( $video_key = get_option( 'video_thumbnails_custom_field' ) ) {
    	$markup = get_post_meta( $post_id, $video_key, true );
    } else {

    to

    if ( $video_key = get_option( 'video_thumbnails_custom_field' ) ) {
    	$markup = 'http://www.youtube.com/watch?v=' . get_post_meta( $post_id, $video_key, true );
    } else {

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.