## filters – Using add_filter to prepend content, result is out of order

Question

I’m using advanced custom fields to add a few fields to my posts. I want to prepend one of these fields to the content. I think I can do this using filters in wp, but I’m getting an odd result.

My filter to prepend a link to the content.

function add_fields_to_content($content) {$acf_library_url = the_field('acf_library_url');
$linkDisplay = '<a href="' .$acf_library_url . '">Link</a>';
return $linkDisplay .=$content;
}



Instead, the url is appearing outside of the <a> element and for some reason the URL of the posts is placed inside the href attribute. I think I’m misunderstanding something about how filters work in WP…