I know that there are similar questions to my question like this one:

Insert php variable in a href

But my problem does not solve with them! I am using "acf plugin" for adding some codes to my wordpress site. Here is the php code that I used in "code-snippet" plugin:

function add_after($content) { if( get_field('article-file') ) { $downloadLink = the_field('article-file'); $aftercontent = '<p class="fontBold">می‌توانید فایل مرتبط با مطالب این صفحه را از طریق لینک زیر دانلود کنید:</p>' . '<a href="' . $downloadLink . '">دانلود فایل</a>'; } else { $aftercontent = null; } $fullcontent = $content . $aftercontent; return $fullcontent; } add_filter('the_content', 'add_after');

I used the the_field('article-file') function of the acf plugin to insert the link of a downloaded file (a custom field called 'article-file') in a href of a tag.The "article-file" custom field was defined as a "file type" of acf custom fields.

But that does not work! the output in the "html" structure of my site is:

<a href="">دانلود فایل</a>

Why the href does not set and show me empty value! Is there any php syntax error in my codes?

hamid-davodi's user avatar

2

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.