I’m using the Advanced custom fields plugin for wordpress and would like to output a field value without any spaces. I need it without any spaces so that the anchor link works properly.
you create a variable called $RoutName which is the string without spaces, but then you echo the original $RouteName, not the copy without the spaces? Also there’s no semi-colon after the echo(), shouldn’t that throw an error message? (Note, I know nothing about Wordpress).
Well, I’m very new to php. I’m trying to figure this out get the return value of the advanced customs field function <?php the_sub_field('route_name')?> then remove all spaces from that string and echo the new value of the variable $RoutName with the spaces of the string removed.
Key thing in either is that you’re creating a new variable called $RoutName, which is a copy of $RouteName but passed through whatever function you choose to remove spaces. So you then have to echo that variable, not the original, or you’ll still get the spaces.
Try taking the php script outside of the unordered list and introducing two additional list items. Also renaming $RoutName to $uriName to avoid confusion.
First list item is ‘XXX’ .$RouteName .‘XXX’ second list item is ‘YYY’ .$uriName .‘YYY’
We’re going to need a bit more information then. When you say “neither works”, what exactly happens? Do you get error messages, the wrong link text, no link text? To start with, what’s in $RouteName and what’s in $RoutName? And can you show more of the code, a few extra lines to show your query, and the start and end of the loop that builds the list?
I believe that there is an error in this code, but I don’t know where. Dreamweaver is coloring the line of code red, but I can’t seem to find the error.