I am working on a PHP loop for WordPress and populating the content with variables.
Currently I have an echo to produce the HTML blocks for the loop that looks like this:
echo '<div class="col-sm-4 retailer" data-state="'.$state.'">
<div class="locationName">'.the_title().'</div>
<div class="locationAddress">'.the_field("address").'</div>
</div>';
However, in the outputted HTML the 2 variables(the_title and the_field(“address”)) are being placed below the content block instead of within their respective divs like this:
<div class="col-sm-4 retailer" data-state="Alaska">
<div class="locationName"></div>
<div class="locationAddress"></div>
</div>Location #1 81234 Sample Dr.
Can anyone tell me why the variables aren’t being contained to the correct divs? Thanks!
Here is the solution that ended up working for me based on tips from @ErkiA and @Twisted1919:
get_title()
grabs the title of the WordPress post andget_field("address")
retrieves the value from a custom field I’ve set up using Advanced Custom Fields.