I've created the following:
<?php $fridayvid = types_render_field("friday-video-id", array( )); ?>
<iframe width="500" height="281" src="<?php echo "//www.youtube.com/embed/".$fridayvid; ?>" frameborder="0" allowfullscreen></iframe>
the custom field 'friday-video-id' is a text field; no values are returning - what am I missing?
Hi andrew,
I can not duplicate same problem in my localhost,
Types types_render_field default output custom fields of current post
I suggest you try debug your codes line by line, like this:
<?php
echo "get_the_ID()": get_the_ID(); // check if it output the correct post ID
$fridayvid = types_render_field("friday-video-id", array( ));
...
?>
If not, for example if your post ID is stored ad $post_id
you can assign $post_id to Types function like this:
$fridayvid = types_render_field("friday-video-id", array( 'post_id'=>$post_id));
Thanks - I will debug this evening and see if it solves the problem or I can see what it is returning instead.
I'll report back my findings/results
Please let me know if you need more assistance
Luoy - your code suggestion caused syntax errors - I was not able to debug at all.
Additionally - it seems types is not returning any values when called via types_render_field in my PHP
<?php $ticketlink = types_render_field("ticket-link", array()); ?>
<a class="share_link" href="<?php echo $ticketlink;?>"></a>
The above returns no value - even though there is data in the field. here's what the HTML looks like
<a class="share_link" href=""></a>
I'm not sure why the plugin is not functioning as it says to use it via the Types Field API suggestions. Am i missing something?
please modify it like this:
<?php
echo get_the_ID(); // check if it output the correct post ID
$fridayvid = types_render_field("friday-video-id", array( ));
...
?>
That returns the number '22'
The page ID for the page that the custom field is pulled from is '41'
Could you post the entire codes of this file, I need check which var store correct post ID.
Please try this:
...
wp_reset_query();
$fridayvid = types_render_field("friday-video-id", array( ));
...
wp_reset_query() restores the $wp_query and global post data to the original main query.
http://codex.wordpress.org/Function_Reference/wp_reset_query
I have done this - and it still isn't placing the value.
<div id="video-gallery">
<div class="container">
<h4>Latest Videos</h4>
<div class="col-md-6">
<?php
wp_reset_query();
$fridayvid = types_render_field("friday-video-id", array( )); ?>
<iframe width="500" height="281" src="<?php echo "//www.youtube.com/embed/".$fridayvid; ?>" frameborder="0" allowfullscreen></iframe>
</div><!-- /.col-md-6 -->
<div class="col-md-6">
<?php $saturdayvid = types_render_field("saturday-video-id", array( )); ?>
<iframe width="500" height="281" src="<?php echo "//www.youtube.com/embed/".$saturdayvid; ?>" frameborder="0" allowfullscreen></iframe>
</div><!-- /.col-md-6 -->
</div><!-- /.container -->
</div><!-- /#video-gallery -->
the wp_reset_query allowed for the ID to now display the proper page ID - but the $fridayvid argument displays nothing still when echoed. I've modified the code to the following and it's outputting nothing still.
<div id="video-gallery">
<div class="container">
<h4>Latest Videos</h4>
<div class="col-md-6">
<?php wp_reset_query();
echo $fridayvid;
$fridayvid = types_render_field("friday-video-id", array("output" => "raw")); ?>
<iframe width="500" height="281" src="<?php echo "//www.youtube.com/embed/".$fridayvid; ?>" frameborder="0" allowfullscreen></iframe>
</div><!-- /.col-md-6 -->
<div class="col-md-6">
<?php $saturdayvid = types_render_field("saturday-video-id", array( )); ?>
<iframe width="500" height="281" src="<?php echo "//www.youtube.com/embed/".$saturdayvid; ?>" frameborder="0" allowfullscreen></iframe>
</div><!-- /.col-md-6 -->
</div><!-- /.container -->
</div><!-- /#video-gallery -->
Luoy - I want to thank you for your help - I was able to solve the problem using the post meta value call I found in the types documentation - a little bit more coding, but it works!
Thanks for all your help!