Support » Plugins » Hacks » Custom area in 'New Post' page for video embed codes?

  • I’ve done some search around the site, and haven’t been able to find what I’ve needed.

    Essentially, we run a news platform where reporters write, but then also embed videos with their standup/pieces included. Right now, I write this code before all their posts, and put our embed links inside the div.

    <div class="video">insert embed code here</div>

    Is there a way I could have a box on the new post page that reporters could paste their embed code into and it would insert this DIV right before the post?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator bcworkz


    Use Custom Fields. While there’s ways to prepend this to the post content, it’s probably easier to output the data directly from inside the loop by altering your templates.

    If you haven’t already, protect your alterations from theme upgrades by creating a Child Theme.

    How would I go about making a custom field where all a reporter would have to do is paste their embed code, and the field would automatically place it into a DIV with the “video” class assigned?

    Here is what I have so far, any idea why this isn’t working? I have this PHP code right before <?php the_content(”); ?> in my single.php file.

    <?php function limelight(){
            $llvalue = get_post_custom_values("limelight");
            $limelight = $llvalue[0];
            return '<div class="video">' + $limelight + '</div>';} ?>

    Then in the custom fields area in my edit post, I have the limelight field with my embed code pasted in.

    Essentially, I just need this embed code to float left and have 5px of padding, which I’ve defined as .video in my CSS file.

    Moderator bcworkz


    Looks like you pretty much have the right idea, except when you want code executed immediately on a template, you do not typically want to wrap the code into a function definition. Remove the function definition and echo the results instead of returning. You will at least get some results then, and if it’s still not right, at least you should be able to see what still needs tweaking.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Custom area in 'New Post' page for video embed codes?’ is closed to new replies.