Home › Forums › General Issues › How to use ACF with LearnPress plugin
hi,
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
https://github.com/LearnPress/learnpress/wiki/How-to-override-LearnPress-templates
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.
Yeah i tried, it works but i can’t figure out how to implement ACF there. I tried with get_field() get_post_field() get_post_meta()
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.
The learnpress lesson page is based on Single page of archive. when i use global $post;
print_r($post->ID); it’s showing the correct ID of lesson
If the global $post is showing the correct post ID then I don’t have an answer based on the information I have and I don’t know what to ask.
I figure out that $post is returning course id not lesson id. Is it possible to get to lesson not using $post?
You will need to talk to someone about the other plugin and how to get the ID you need inside of the template you are overriding.
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!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.