Displaying the Image Custom Field with PHP
-
Hi,
For a few days I been guessing and trying to get this code right but I can’t seem to figure it out… Could you please help me out? I don’t know how to code but I try lol.
I made an images custom field group with Toolset Types, that I want to display on the front end of my custom post types.
*The group is called:
Additional Images
*These are the fields:
Field name Image 1
Field slug image-1
Field type imageField name Image 2
Field slug image-2
Field type imageField name Image 3
Field slug image-3
Field type imageFrom: https://wp-types.com/documentation/functions/#image
(BTW, excellently written! The most simple and organized codex I ever seen!)I take that I should add a code like this:
<?php types_render_field( "image-1", array( "alt" => "blue bird", "width" => "250", "height" => "188", "proportional" => "true" ) ) types_render_field( "image-2", array( "alt" => "blue bird", "width" => "250", "height" => "188", "proportional" => "true" ) ) types_render_field( "image-3", array( "alt" => "blue bird", "width" => "250", "height" => "188", "proportional" => "true" ) ) ?>
The above gave an error so I tried the below code … and many more:
<?php echo types_render_field( "image-1", array( "alt" => "Additional Image", "width" => "250", "height" => "188”, "proportional" => "true" ) ); echo types_render_field( "image-2", array( "alt" => "Additional Image", "width" => "250", "height" => "188”, "proportional" => "true" ) ); echo types_render_field( "image-3", array( "alt" => "Additional Image", "width" => "250", "height" => "188”, "proportional" => "true" ) ); ?>
No success.
Could you please show me how could I make them appear on the front end?
Also, the three images are meant to be display on the same line horizontally.
For example:
————————————————
IMAGE 1 – IMAGE 2 – IMAGE 3
LEFT —– CENTER —– RIGHT
————————————————I have absolutely no idea of how to achieve that with the required php.
Do I need to use something like the below code somehow?:
<div <img style=" float:left; display:inline" src=" <img style=" float:center; display:inline" src=" <img style=" float:right; display:inline" src=" </div>
Your help and advice would be stress relief!
Thanks!!
- The topic ‘Displaying the Image Custom Field with PHP’ is closed to new replies.