Home Forums Types Community Support [Closed] adding post_id parameter to types_render_field() function

[Closed] adding post_id parameter to types_render_field() function

This topic contains 7 replies, has 2 voices, and was last updated by  mery 2 years, 8 months ago. The support staff assigned to this topic is bruce.

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

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 ?



Forum moderator

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,


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 ?



Forum moderator

Hi Thomas,

The latest version is 1.0.4 - http://wordpress.org/extend/plugins/types/

Best regards,


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 ?



Forum moderator

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,


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 :

$post_id = $params['id'];
$post_id = $post->ID;

and using this variable instead of $post->Id in the get_post_meta calls


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


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

The topic ‘[Closed] adding post_id parameter to types_render_field() function’ is closed to new replies.

Support Policy

Toolset staff will help you use Types, Views and CRED correctly, provide any information you need, help troubleshoot problems and advice on best-practices.

Please make sure to issue only one topic per each support ticket.

Need custom programming work for your site? Check out our certified partners.