Grow your CSS skills. Land your dream job.

WORDPRESS: Custom Fields data not displaying on template?

  • # June 30, 2013 at 3:22 pm

    I followed [this](http://wp.tutsplus.com/tutorials/creative-coding/youtube-and-vimeo-video-gallery-with-wordpress/ “http://wp.tutsplus.com/tutorials/creative-coding/youtube-and-vimeo-video-gallery-with-wordpress/”) tutorial.

    Created my [Custom Post Type](http://pastebin.com/izt0bbqh “http://pastebin.com/izt0bbqh”), added Custom Fields (Text Input & Select Menu), then I named the fields “videoid” and “videosite” .
    The data remains when saved but the data isn’t called correctly within my page template :(

    When I view the page it says “Please select Video Type…”
    As if nothing was entered into the custom fields…

    If I use the easy method (Custom Field Template & Custom Post Types UI) Plugins, everything works, no errors or blank pages. But when I add the actual CPT and Fields to my functions.php it ends up not working…

    Why is that? What did I do wrong?

    Please Help :(

    **PHP** Used to get the video//

    < ?php
    /* Set variables and create if statement */
    $videosite = get_post_meta($post->ID, 'Video Site', single);
    $videoid = get_post_meta($post->ID, "Video ID", single);
    $selected_id = get_the_ID();
    if ($videosite == vimeo) {
    echo '';
    } else if ($videosite == youtube) {
    echo '';
    } else {
    echo 'Please Select a Video type.';
    }
    ?>
    # June 30, 2013 at 5:40 pm

    Anyone?

    # June 30, 2013 at 5:49 pm

    go with a step by step debugging.
    first make sure you check for a string

    if ($videosite == ‘vimeo’)

    in your code you are missing the quotation marks

    then you can start echoing the $videosite variable after you have made sure that when you save a value in your post and save it it gets saved, meaning that after a refresh it stays in the placeholder

    # June 30, 2013 at 6:06 pm

    @pixelgrid wow another simple error. Thank you very much for pointing it out! The videos are now displayed :D

    # July 2, 2013 at 3:10 am

    @pixelgrid Not sure what happened here but the videos aren’t working again. I added the quotation marks and it worked for a little while but now, the video container is empty again…

    :(

    Do you mind looking through a new pastebin to help out please?
    I am not sure if it’s the way my CPT is set up or my Custom Fields…
    *sigh*

    # July 2, 2013 at 2:38 pm

    Anyone have spare time on their hands?

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".