Order of output changes in php echo

2019-03-03 18:42发布

问题:

Hopefully this is a simple fix, for some reason when I run this. I am running wordpress and using the advanced custom fields plugin

echo "Tickets Start at CA$" . the_field('price');

I get this output

50Tickets Start at CA$

Instead of, what I want to happen which is

Tickets Start at CA$50

Any ideas what I am doing wrong

回答1:

Indeed, as @smith says the_field() displays the value of the field. You want to use get_field() instead which returns the value instead of displaying it.