Skip Navigation

[Resolved] Repeater field shows URL, I would like it to be a URL

This thread is resolved. Here is a description of the problem and solution.

Problem:
The user would like to build a link that will include an image from a radio field and the URL from a URL field. the user would like to build this inside a theme template.

Solution:
It turns out that the user did not use echo to return the values of Toolset Types functions:

<a href="<?php echo types_render_field("file", array("id"=> $child_post->ID, "output" => "raw")); ?> ">
    <img src="<?php echo types_render_field( "file-type", array( "id"=> "$child_post->ID")); ?>">
    <?php echo $child_post->post_title; ?>
</a>

Relevant Documentation:

This support ticket is created 4 years, 3 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 - - 9:00 – 13:00
14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 - - 14:00 – 18:00

Supporter timezone: Africa/Casablanca (GMT+01:00)

This topic contains 8 replies, has 2 voices.

Last updated by chantelleL-2 4 years, 3 months ago.

Assisted by: Jamal.

Author
Posts
#1822603
output.PNG

Ive got a set of repeater fields which are

Select file - called file
Radio buttons - File type (depends on option this shows an image)

My code is

<?php
$child_posts = toolset_get_related_posts( get_the_ID(), 'document-link', array( 'query_by_role' => 'parent', 'return' => 'post_object' ) );
foreach ($child_posts as $child_post)
{ ?>

<div class="car-listing">
<h5><?php echo $child_post->post_title; ?></h5>
"$child_post->ID")); ?> ">
"$child_post->ID")); ?>">
post_title; ?>

</div>
<?php } ?>

The image and Title works fine.... however

This "$child_post->ID")); ?> "> prints the url like

hidden link">

On chrome I inspect the element:
hidden link">hidden link;

I need this to look like

hidden link"><img src="/wp-content/uploads/2020/10/file_pdf_download_icon-icons.com_68954.png">Referral vs Partner Programme summary

#1823265

Hello and thank you for contacting the Toolset support.

The types_render_field function will return a repeater field results separated with comma(,) by default. Unless you define a different separator. Check this article it may help if you need to have HTML markup for the separator https://toolset.com/documentation/customizing-sites-using-php/displaying-repeating-fields-one-kind/#using-html-separators

Or you may use the PHP explode function to build an array from the results of the function hidden link

Note that you can use the output argument to get the raw URL
- https://toolset.com/documentation/customizing-sites-using-php/functions/#file
- https://toolset.com/documentation/customizing-sites-using-php/functions/#radio

I hope this helps. Let me know if you still have any questions.

#1823819
#1823919

Can you try this instead:

<a href="<?php types_render_field("file", array("title" => "read me...", "output" => "raw")); ?> ">

If this does not help, please log in to this test site with the following URL and prepare an example of what you are building. Let me then integrate the link. hidden link

#1823923
Capture.PNG
Capture1.PNG
Capture2.PNG
Capture3.PNG
Capture4.PNG
output1.PNG
Inspect element.PNG

Hi

That would take a lot?

I need to download the toolset plugin, the theme template files and then create the post type etc..

Can I not send you credidentials for a dev site and send you a PHP of the page template?

Ive attached images on custom fields set up, the edit page bit, what it looks like on template, what the template code is and what the Chrome inspect element shows too.

#1824011

We can do that too. Your next reply will be private to let you share credentials safely. ** Make a database backup before sharing credentials. **

#1824685

Your code had two issues:
- It did not use the id attribute "id"=> $child_post->ID for the file field.
- It did not use echo to display the results on the page.

I fixed it with the following code:

	<a href="<?php echo types_render_field("file", array("id"=> $child_post->ID, "output" => "raw")); ?> ">
		<img src="<?php echo types_render_field( "file-type", array( "id"=> "$child_post->ID")); ?>">
		<?php echo $child_post->post_title; ?>
	</a>

Check the resulted links in this screenshot hidden link

#1824689

Thank you

#1824691

My issue is resolved now. Thank you!