I'm new to php. I have the following line in a functions.php file of my WordPress site. I think there is something wrong with the way I formatted get_the_bag
. Can someone let me know what is wrong?
$output .= "<span class='bag-item'>. get_the_bag(); .</span>";
;
) after your function callYou want:
$output .= sprintf("<span class='bag-item'>%s</span>", get_the_bag());
Or
$output .= "<span class='bag-item'>" . get_the_bag() . "</span>";
(Both assuming that get_the_bag
returns an HTML safe string. If it doesn't you need to wrap that function call with htmlspecialchars
).
Remove the semicolon from after get_the_bag()
and place speechmarks after the first span and before the second:
$output .= "<span class='bag-item'>". get_the_bag() ."</span>";
try this
$output .= "<span class='bag-item'>" . get_the_bag() . "</span>";