Skip Navigation

[Resolved] Add field not just value

This support ticket is created 2 years, 8 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: Asia/Karachi (GMT+05:00)

This topic contains 11 replies, has 2 voices.

Last updated by colinb-4 2 years, 8 months ago.

Assisted by: Waqar.

Author
Posts
#2108199
single.png

Tell us what you are trying to do?
Add field not just value

Is there any documentation that you are following?
Yes the advice to add the code <?php echo(types_render_field( 'franchise_initial ', array( 'show_name' => true ) )); ?>
to single.php is not working when I try to respond to support I receive an error please supply an email to respond to issue

Is there a similar example that we can see?

What is the link to your site?
hidden link

#2108257

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

I've tested the same code in the same location in the "single.php" file on my test website and it worked as expected.

Can you please test this again after removing the opening PHP tag?
( screenshot: hidden link )

In case the issue still persists, you're welcome to share temporary admin login details in reply to this message.

Note: Your next reply will be private and please make a complete backup copy, before sharing the access details.

To reply to an existing support ticket, please make sure that you're logged in using the same Toolset account that was used to start the ticket. We can continue this investigation through this new ticket and you can mark the earlier ticket as resolved.
( ref: https://toolset.com/forums/topic/show-field-name-not-just-value/ )

regards,
Waqar

#2109157

Good Evening,

Just checking if you have resolved this issue?

cheers Karmen

#2109871

Hi Waqar,
I still have not had this issue fixed the fields are not showing but the value is.

#2109965

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for sharing these details and I apologize for the delay.

I see that the code for the custom field is added in the theme's "single.php" file after the "get_footer()" function.
( screenshot: hidden link )

If you'll check any single "Find a Franchises" post, for example {yourwebsite.com}/find_a_franchise/school-rock/ you'll see that the field's name and the value is showing below the footer, as expected.
( screenshot: hidden link )

This confirms that the code is bringing in not just value but also the field name.
( for example in "Initial Fee: $49,900". "Initial Fee" is the field name and "$49,900" is the value ).

Note: the content in the single "Find a Franchises" post pages, is managed by the content template named "Template for Find a Franchises":
{yourwebsite.com}/wp-admin/post.php?post=9555&action=edit

You can edit the content area of those pages through this content template without having to add the code directly in the "single.php" file.

Here is a guide on using the content templates:
https://toolset.com/lesson-placement/lesson-placements-1621067-1621091/

#2110075

Thank you for the information.
I am new to toolset and am trying to understand If I want the multiple field information in the template for find a franchises inside the main text boxes where exactly should I put that code provided to include the field and the value?

#2110365

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

In the content template "Template for Find a Franchises", I noticed that you've already added this shortcode to show the "franchise_initial" field value:


[types field='franchise_initial'][/types]

I've updated that shortcode to include the show_name='true' attribute and it is now showing the field name and the value:
( screenshot: hidden link )


[types field='franchise_initial' show_name='true'][/types]

It is important to note that the PHP code that you shared in the first message is only needed when you are working with the theme's PHP files.

But, using a content template, the content editing becomes much easier, as you don't have to add PHP code directly.

In the content templates, you can use the available blocks and shortcodes, to generate the desired content:
https://toolset.com/documentation/customizing-sites-using-php/functions/

Note: If you've just started working with the Toolset plugins, I'll recommend going through the basic free course on building a WordPress directory website:
https://toolset.com/course/wordpress-directory-and-classifieds-sites/

This way you'll become familiar with the Toolset's features and options, more efficiently.

#2111317

Thank you so much for your help Waqar,

I am also wanting to bold just the field not the value I have inserted the code <span style="font-weight: bold;">[franchise_invest="Minimum Investment"]</span> but it is bolding the field and the value how to you separate the field to be bold the value to normal font weight.

#2111963

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

If you'd like to bold just the field's name and not the value, then you'll need to add the field name manually and use the type's field shortcode, only to show the value.

For example, you'll replace:


[types field='franchise_initial' show_name='true'][/types]

With:


<strong>Initial Fee:</strong> [types field='franchise_initial'][/types]

#2114965

Thank you Waqar,

If I am using Initial Fee: [types field='franchise_initial'][/types]
and in some cases this value is empty.

I want to remove the field name and remove the space is that possible?

#2115029

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

For an empty value check, you can wrap the field's code in a conditional check:


[wpv-conditional if="( NOT(empty($(wpcf-franchise_initial))) )"]
<p><br><strong>Initial Fee:</strong> [types field='franchise_initial'][/types]</p>
[/wpv-conditional]

We have a guide on the topic at:
https://toolset.com/documentation/legacy-features/views-plugin/checking-fields-and-other-elements-for-emptynon-empty-values/#1-using-the-empty-function

#2120497

My issue is resolved now. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.