Hello @max1024
Where are you using the template code?
This is intended for a Pods Template. The function itself should be added in your theme.
Cheers, Jory
Hi
sure, im using it with pods plugin
function is in functions.php
So function is called ok, but ID comes empty
How are you fetching the Pods Template?
A shortcode? Auto-templates? Something else?
Cheers, Jory
Hi @max1024
I’d need a bit more than just “shortcode”..
– Please share your shortcode (just copy it)
– Also let me know where this shortcode is used in your site
You’ll need to share all related info about this issue otherwise it’s impossible for me to properly help you.
Cheers, Jory
On page:
[pods name=”course” id=1 template=”ListCourseDetails”]
template:
<div class=”row”>
<div class=”col-6″>Total hrs:</div>
<div class=”col-6″> {@ID,calculateHours}</div>
</div>
Function:
function calculateHours($id) {
$course = pods(‘course’, $id);
if ($course->exists()) {
return $course->filed(‘hours’)+$course->filed(‘conshours’)+$course->filed(‘examhours’)+$course->filed(‘projecthours’);
} else return $id;
}
-
This reply was modified 3 years, 4 months ago by max1024.
Hi @max1024
And you say that the $id parameter is empty in your function? Did you check with a var_dump
or something similar?
If so, I cannot reproduce your issue locally so there must be something else wrong. Maybe a plugin conflict? https://docs.pods.io/faqs/plugin-theme-conflicts/
I also noticed you are calling a method I do not recognize named filed
. This isn’t a method from the Pods object.
Shouldn’t this be field
?
Cheers, Jory
Closing topic due to no reply.
Feel free to re-open if you still need help!
Cheers, Jory