Hi there,
seems to me that this very useful function can only be used in the loop (as there is no way fo now to change the post it gets the custom fields for)
would be very useful to be able to pass a post_id in the arguments as right now I have to modify global $post before calling this function to achieve what I am after
Would the Types team comment in this ?
thanks
Hi Thomas,
It can't be done via the types_render_field function. You can use it in the types shortcode.
[types field='my-field' id='233']
To use it in your theme you can use something like:
<?php echo do_shortcode("[types field='my-field' id='233']"); ?>
Best regards,
Bruce
Hi ruce,
thanks for the reply
only I can't make it work and I don't see how this is implemented in the code
nothing indicates that an id param is used in case it exists (in frontend.php)
I'm using Types 0.1
is there a newer version ?
thanks
Hi Thomas,
The latest version is 1.0.4 - http://wordpress.org/extend/plugins/types/
Best regards,
Bruce
thanks Bruce,
this is in fact the version I am using
only in types_render_field()
global $post is used to get meta information
no way to pass an id there as far as I can see
any chance you might share where this is supposed to happen ?
thanks
Hi Thomas,
It only happens when called via the types shortcode. The line that does it is line 32:
// Switch the post if there is an attribute of 'id' in the shortcode.
$post_id_atts = new WPV_wpcf_switch_post_from_attr_id($atts);
Best regards,
Bruce
Ah thanks
only I am not using shortcodes
but rather accessing the types_render_field directly in my template
any chance the Type Team will consider adding a way to use $args['id'] in the types_render_field function to achieve the same result without having switch the global $post ?
It would be cleaner I think
Maybe I am missing something but could something along the line of :
if(isset($params['id']))
$post_id = $params['id'];
else
$post_id = $post->ID;
and using this variable instead of $post->Id in the get_post_meta calls
work
as it seems like $post is used mainly to get its ID
it seems to be working for me
let me know hat you think
thanks