Home › Forums › General Issues › Shortcode without postid
Hi, I’m working in Learndash/Woocommerce/Wordpress.
I run 20 different courses for tax preparers. There’s info that the IRS requires me to put on the completion certificate that LearnDash doesn’t have a place for, so I got ACF. I’d like to create one master certificate. LearnDash can put the student name on, great, and the date, also great, and I think the course title, but that’s being a bit wonky.
But I need the IRS number and the number of credits. So I’m trying to use ACF for that. I can enter those numbers at the exam level, no problem.
The problem comes when the shortcode (example: <div style=”width:290px;margin:auto;text-align:center;”>[acf field="irs_course_number_exam post_id="1120"]</div>) wants that post id. If I want the one certificate to draw from the exam they just took, then I can’t specify the post id.
Can I set up the shortcode without a post_id?
The only way to use the shortcode is to know the ID of the course that was taken. Without the post ID in the shortcode then ACF uses the ID of the current post. I have not used what you are using so I have no idea what the current post would be in your situation.
So is there a way to get ACF to know what course sent the user to the certificate? I’m hoping to have one master certificate that dynamically populates: you take Course A, the certificate fills out with your name, the course name (both of which I can do using LearnDash) and the number associated with that course using ACF.
You take course B, the same certificate master, but now the the number associated with Course B that I put in course B using ACF.
Does that clarification help?
That information would need to be communicated between learndash and whatever you are using to create the certificate. But in any case there isn’t going to be a way to use a shortcode unless you build a custom shortcode that uses PHP to retrieve the post ID of the course from whatever method is used to transfer that information to the certificate.
So this instruction includes a php (https://developers.learndash.com/snippet/certificate-custom-user-field-and-shortcode/) but it’s massive overkill, involving dynamically changing logos.
All I want is what the template already does, when associated with a course, fills in info from the course, but I want it to include the ACF field, which is a simple, 3-line text field.
Can someone help me modify the code in that snippet to just do that one thing?
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.