Skip Navigation

[Resolved] Split: Showing the two custom fields connected in the intermediary post

This support ticket is created 2 years, 5 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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)

Author
Posts
#2376331

Hello Luo, it worked perfectly. I had to do a workaround (like use the old legacy mode)for these codes that did not work with the toolset blocks (for it always displays an error "This block encounter a fatal error". but I follow the logic. thanks

I have one more detail related to this ticket. I can not get two custom field data to display. It only displays the post title connected in the relationship, and it does not show the two custom fields connected in the intermediary post title. Do I have to open a new ticket?

Thanks

#2376337

Hi,

Thank you for contacting us and I'd be happy to assist.

Can you please share temporary admin login details, along with the link to the example page, where you'd like to show the custom fields from the intermediary post?

I'll be in a better position to guide you with the next steps, accordingly.

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

regards,
Waqar

#2377095

Thank you for sharing these details.

The three views that you referred to all are set to show the "Conference Member" posts. In the views which are showing the "Conference Member" or the "Church" posts, you can use the item attribute to show the custom fields from the related intermediary "Appointment" post:
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/item-attribute/

For example:


Appointment Date: [types field='ch-appmt-date' style='text' format='F j, Y' item='@appointment.intermediary'][/types]

Appointment term: [types field='ch-appmnt-term' item='@appointment.intermediary'][/types]

Appointment End Date: [types field='ch-appmt-end-date' style='text' format='F j, Y' item='@appointment.intermediary'][/types]

As for calculating the time difference between the two dates, you'll need a custom shortcode, for example:


function calculate_date_difference_func($atts = [])
{
	$atts = shortcode_atts([
		'start' => '',
		'end' => '',
	], $atts);

	$timestamp1 = (int)$atts['start'];
	$timestamp2 = (int)$atts['end'];
	$hour = abs(($timestamp2 - $timestamp1))/(60*60);

	return $hour." hour(s)";

}
add_shortcode( 'calculate_date_difference', 'calculate_date_difference_func');

The above code snippet can be included through either Toolset's custom code feature ( ref: https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/ ) or through the active theme's "functions.php" file.

Next, please add "calculate_date_difference" in the "Third-party shortcode arguments" section, at WP Admin -> Toolset -> Settings -> Front-end Content.

After that, you'll be able to use the shortcodes for the start and end date fields, inside this new custom shortcode, like this:


[calculate_date_difference start="[types field='product-start-date' output='raw' item='@appointment.intermediary'][/types]" end="[types field='ch-appmt-end-date' output='raw' item='@appointment.intermediary'][/types]"]

I hope this helps and for more personalized assistance around custom code, you can also consider hiring a professional from our list of recommended contractors:
https://toolset.com/contractors/

#2377599

My issue is resolved now. Thank you!