I want to add via ACF for example File to LearnPress Single Lesson. I dont want to use editor, it should be by ACF. In WP admin panel everything is correct setup.
I also create a folder in my theme THEME/learnpress/content-lesson and in it file named content.php
In there I create php function to display ACF but doesnt work:
<?php global $post; if(get_field('file', $post->ID)) : $file = get_field('file', $post->ID); ?> <div class="acf-lesson"> <a href="' . $file . '">Test</a> </div> <?php endif; ?>
I found this
Are you trying to override a template or add content on one of the hooks?
If you are overriding a template then make sure you have it in the right place. If you are trying to use one of the hooks in a template then you’ll need to add an action in your function.php file.
The only thing that I can think of is that the global $post is not pointing to the post where you’ve added the fields. Sorry, I don’t know anything about LearnPress. You will need to ask them how to determine the correct post ID value to use for ACF in that template.
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
📣 “ACF Chat Fridays”— Advanced Custom Fields (@wp_acf) January 31, 2023
The ACF team holds their first open office hours this Friday! Come and talk ACF, and ask questions about building sites with the plugin.
We’d love to see you there!
📆 Friday 3rd Feb - 3pm UTC
👉 Register here - https://t.co/3UtvQbE4CU pic.twitter.com/oTwW9K1XQ0
© 2023 Advanced Custom Fields.