The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End WORDPRESS: Custom Fields data not displaying on template?

  • This topic is empty.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
  • #45983

    I followed [this](”) tutorial.

    Created my [Custom Post Type](”), 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//

    /* 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.';



    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


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


    @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…


    Anyone have spare time on their hands?

Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘Back End’ is closed to new topics and replies.