Skip Navigation

[Resolved] Making the address put each section on a new line and adding prefix titles

This support ticket is created 4 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 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

Tagged: 

This topic contains 9 replies, has 2 voices.

Last updated by neilM-12 4 years, 7 months ago.

Assisted by: Shane.

Author
Posts
#1578763

Hi,

i need to split my company addresses so they appear on each line... For example on hidden link this should appear so that where the commas are thats a new line. I would like this to happen for all records.

Also how do i add a prefix icon before the telephone, email and website.......

Thanks

Neil

#1578923

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Neil,

Thank you for getting in touch.

In order to actually do this you will need a bit of custom code to split the items into a new line based on the commas.

What I did was to draft up a quick shortcode that should be able to get this done for you.

// Add Shortcode
function wp_split_address( $atts ) {

	// Attributes
	$atts = shortcode_atts(
		array(
			'address' => '',
		),
		$atts
	);

	$address = str_replace(',','<br />',$atts['address']);
	return $address;

}
add_shortcode( 'wp_split_address', 'wp_split_address' );

Add the following to your toolset custom codes in Toolset -> Settings -> Custom Code and ensure that you activate the code.

Once you have done this then you can use the shortcode like this.

[wp_split_address address="types shortcode goes here"]

Please try this and let me know if it resolves the issue for you.

Thanks,
Shane

#1580309

I managed to do the easy bit and create the custom code called split_address by cannot see how to add this as a field or do i apply this to the existing multi field somehow?

#1580787

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Neil,

The example usage can be seen below.


[wp_split_address address="types shortcode goes here"]

Where you will replace the "types shortcode goes here" with the shortcode that you are using to display your address.

Assuming that your field is an address field created in types then you would have something like this


[wp_split_address address="[types field='my-address'][/types]"]

However to be 100% sure how you are displaying the address, could you send me screenshot of the actual field on the backend as well as the template where you've added the address field ?

If you are using the types shortcode to display the address then you can use the shortcode above. If you are not then I would need to provide a guide on how you can still achieve this because the custom shortcode that I gave requires that the field is called using a shortcode.

Thanks,
Shane

#1585567

Hi Shane,

Getting this error.....

Snippet "split_address" has been updated.
There was error when trying to re-run the snippet:Unexpected output of the code snippet: // Add Shortcode function wp_split_address( $atts ) { // Attributes $atts = shortcode_atts( array( 'address' => '', ), $atts ); $address = str_replace(',','',$atts['address']); return $address; } add_shortcode( 'wp_split_address', 'wp_split_address' );

I also am not sure how to add this into my layout in blocks.

Appreciate your help.

#1585751

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Neil,

It seems that there is a missing closing tag somewhere in the code.

Would you mind allowing me to have admin access to the website so that I can have a look at what was added to the custom snippets section ?

I can also set up the code so the address starts splitting for you.

The private fields will be enabled for your next response.

Thanks,
Shane

#1586927

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Neil,

Thank you for the credentials, however they don't seem to be working.

Could you check them on your end and let me know ?

Thanks,
Shane

#1604185

Hi Shane,

Just edited my previous post... i missed the last character off the password!

Thanks for your help.

Neil

#1604337

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Neil,

I've resolved the issue and the address should now be showing in multiple lines.

Thanks,
Shane

#1610797

My issue is resolved now. Thank you!