• Hi,

    I’m trying to display the value of a custom text field in my theme’s single.php. So here’s the code I’ve added:

    <?php types_render_field("wpcf-price",array('output'=>'html')); ?>

    It just does not work and the field is never displayed.

    Is this the right way to do this or do I have to use the embedded types features? Is there any thing I’m missing here?

    thanks,
    m

    https://www.ads-software.com/extend/plugins/types/

Viewing 15 replies - 1 through 15 (of 24 total)
  • I have the same issue (and I saw it posted last week as well). According to the API, that’s correct. My guess is it’s busted.

    Embedding is a poor way to implement this imho – you can’t customize the layout as easily or trust others to get it right. I guess it’s a way to try to sell Views. I’m sure I could get it to work with Views, but I’m not going to buy a module to ‘add’ functionality that supposedly exists. I assume Views is similar to Drupal Views (which would make it worth the price).

    It’s disappointing – this is sorely needed in WordPress.

    Plugin Author Amir Helzer

    (@amirhelzer)

    There are different reasons for the field not to display.

    You added the output to single.php. Does the field belong to a post, or something else? single.php is for posts.

    Did you try to insert that output inside the post body using the Types icon? Does it display there?

    Is the name of the custom field correct?

    Are you getting any PHP errors?

    Any solution? I am having the same problem. ??

    I found an alternative solution:
    <?php echo do_shortcode(‘[types field=”hotel_full_business_name”]’); ?>

    Put this on your template and it works. ??

    Plugin Author Amir Helzer

    (@amirhelzer)

    Folks, you’re reporting something wrong, but you’re not giving us anything to work on. It’s working on our tests.

    Can you provide complete debug information? I asked a set of questions above and I’m not getting any replies to any of them.

    Remove ‘wpcf-‘ prefix from field name. It’s prefix for internal usage. We should make that clear in our docs.

    Also echo returned result:
    <?php echo types_render_field(“price”, array(‘output’=>’html’)); ?>

    thanks for the replies.. Now it works. ??

    And i have to agree, this should be made more cleared on the docs. ??

    Thread Starter plannerguy

    (@mdlepage)

    @amirhelzer, @jozik
    Ok, took a while to get back to you.

    I removed the “wpcf” prefix, added the echo to the php statement and now it works.
    Thanks for the help.
    Updating your documentation with help avoid more posts like this.

    ??

    Plugin Author Amir Helzer

    (@amirhelzer)

    I added a note about this in the documentation page. There’s no need for each. types_render_field sends to output.

    Great to see this is cleared up. I’d also recommend adding the echo to your real-world example on your documentation page.

    So this: <?php echo types_render_field("field-name", array("arg1"=>"val1","arg2"=>"val2")); ?>

    instead of this: <?php types_render_field("field-name", array("arg1"=>"val1","arg2"=>"val2")); ?>

    I added it (my issue was the prefix), but I can see how someone might not. There’s never a danger in being too clear.

    Phew! I had the same problem. I didn’t understand that I had to have the echo in there either. And do_shortcode wasn’t as helpful because I was showing an image and needed to specify ‘medium’ and some other parameters. Thanks, everybody.

    I’m really excited about this plugin. Its the cleanest of all the ones out there like it that I have seen. Would like to be able to put ‘alignleft’ on the image like you can in the wordpress interface.

    guys, I must concur; you need to put the ‘echo’ in your example. That’s how I ended up here too.

    Seems to be a great plugin; I’ll probably check out ‘view’ as well. Thanks for your work!

    Plugin Author Amir Helzer

    (@amirhelzer)

    That’s pretty guffy of me. You’re right. There’s no echo. I added it to the documentation page. Sorry about that.
    https://wp-types.com/documentation/functions/

    thanks Amir.
    I’ve been using a blank cpt template up to now, but came across your plugin. I think I’ll be switching to Types from now on in. Great plugin. thanks again.
    ken

    Hi guys,

    I’m sorry I cannot make this thing works…I need some help I guess.

    I need to display some custom fields to my posts using “Types”.

    After creating the group in Types and setting the conditions, the field is perfectly displaying on my posts in “edit mode”. After adding content to the field, it does not shows up on my page in the “online page version”.

    To display the field, after reading your answers, I’ve added the following code to single.php :

    <?php echo types_render_field(“vineyard”, array(“show_name”=>”true”,”output”=>”html”)); ?>

    Unfortunately, nothing happens…

    Any ideas?

    Thanks a lot.

    PS: I still don’t have “views” (for the moment ^^)

Viewing 15 replies - 1 through 15 (of 24 total)
  • The topic ‘[Plugin: Types – Custom Fields and Custom Post Types Management] render custom field in theme’ is closed to new replies.