jamesburden
Forum Replies Created
-
Thanks @polarracing – I think I’ve got it now ?? Appreciate the guidance very much indeed.
Hi @polarracing – I’m so sorry – I’m sure I’m missing something obvious. I’m still trying to wrap my head round how CCS and shortcodes work.
I’ve added your function exactly as is. And I’ve added the [mri-phone…] shortcode. But what do I put in place of ‘{PASSED_VALUE}’?
I understand I need the value to come from the ACF ‘phonenumber’ field. What is the passed_value? Is it the ACF field name or ID? Or something different? I’ve tried a number of permutations – none of which seem to work.
Thanks so much for your patience!
@iantresman – thanks! Yes, I’ve already been through those pages with no success in this particular situation.
Hmm – I’ve tried the code I posted above and it doesn’t work. I’ve obviously got something wrong with the code to create the shortcode.
If anyone has any guidance on how I can resolve this I’d be very grateful!
@polarracing – I’ve just been trying to understand a bit more about creating the shortcode and how to pass the ACF value to it. So should the shortcode function read as follows?:
function trimnumber_function() { $phone = get_field_object('field_6061b942fa7a2'); preg_replace("/[^0-9]+/", "", $phone); } add_shortcode( 'trimnumber', 'trimnumber_function' );
And then I can reference
[trimnumber]
as shortcode that has removed the spaces from the original phonenumber field?Thanks @iantresman – that looks interesting if it is just UK numbers and if they are always entered in the same number groupings. But I’ve got hundreds of phone numbers across 130 different country codes and formats. Even within countries, the numbers are not uniformly entered in the same grouping. But I hadn’t used the set shortcode before – so that’s a useful tool to have!
Am hoping I can get my head round this shortcode approach. I think that will be really useful to learn.
Thanks @polarracing – really appreciate your help.
I’m just starting to learn the ropes with php and how to create my own shortcodes.
So am I right in thinking that I need to create a snippet that creates a shortcode like this:
function trimnumber_function() { preg_replace("/[^0-9]+/", "", $phone); } add_shortcode( 'trimnumber', 'trimnumber_function' );
And then on the front end I reference that shortcode like this:
[repeater offices_0_phone] [field phonename]: <a href="tel:[trimnumber]">[field phonenumber]</a> [/repeater]
But how do I tell the shortcode that $phone is the value of my custom field which has an ACF name of phonenumber and an ACF key of field_6061b942fa7a2 ? Do I need to replace $phone in the shortcode function with the ACF key somehow?
Apologies if this is really basic – just trying to learn how to do this and build on it in the future!
- This reply was modified 3 years, 11 months ago by jamesburden.
For some reason the formatting of my shortcodes keeps resetting in the post above. The phonenumber field after ‘tel:’ is surrounded by square brackets of course.
Thanks so much – that’s really helpful.
Thanks so much – really appreciate the quick response. I’ve been experimenting with this and trying to get my head round
pass list
but not sure I quite understand it. Is there any further information available on how to use this? I’ve also been looking on the information / help pages within the plugin settings. But any further light you can shed on it would be very helpful.Forum: Plugins
In reply to: [SearchWP Modal Search Form] installation causes fatal errorAwesome! Thanks so much ??
Forum: Themes and Templates
In reply to: fatal error on changing to standard_themeBrilliant – just figured out how to do this. I hadn’t realised that i needed to use my host server username rather than my wordpress username. Seems obvious now. Thanks for taking time to reply.