WordPress.org

Forums

Custom area in 'New Post' page for video embed codes? (5 posts)

  1. kylecesmat
    Member
    Posted 2 years ago #

    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?

  2. bcworkz
    Member
    Posted 2 years ago #

    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.

  3. kylecesmat
    Member
    Posted 2 years ago #

    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?

  4. kylecesmat
    Member
    Posted 2 years ago #

    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.

  5. bcworkz
    Member
    Posted 2 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.