Skip to content
Advertisement

How to display sub field (image) with shortcode in WordPress?

These are the custom fields composition:

1 Group Footer

1.1 Group Col2

1.1.1 bbcimg (this is the image ID)

1.1.2 bbc-rss (this is the RSS feed ID)

I have the following code displaying the bbc-rss:

JavaScript

I have created the image field bbcimg with the following properties:

  • Field label: bbcimg
  • Field Name: bbcimg
  • Field Type: image
  • Instructions: –
  • Required: No
  • Return Format: Image Array
  • Preview Size: Medium(300×300)
  • Library: All
  • Minimum: Width 40px, Height px 40 File size – MB
  • Minimum: Width – px, Height px – File size – MB
  • Allowed file types: –
  • Conditional Logic: –
  • Wrapper Attributes: –

And the image is already uploaded in the custom field. See picture: enter image description here

Question:

How to write the logic to display the picture on the website?

Thank you very much in advance!

been trying to use

Advertisement

Answer

First you need to find out what is getting returned inside the custom field. Add a good old print_r to your code somewhere:

JavaScript

That will print out an array of values like Array( ‘url’ => ‘http….something.jpg’, ‘size’=>’full’, ..etc)

Then you can identify which array value gives you the full URL to the image. Say in this case it would be a field called url, then you can use that value as follows:

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement