Show $post_id via javascript function
-
Hi…
In comment_template.php there’s the id of the active post. In PHP, it’s $post_id.
If I do this in comment_template.php:
echo $post_id
The post id shows up in just above the comment:
<img src="https://dalcotech.com/d3/dtest.jpg" alt="dtest" />
How do I show it in a javascript function that I can call. This doesn’t work:
function getJSPostID() { try { var test='<?php echo $post_id; ?>'; return test; } catch (e) { return 'unavailable'; } } var ID = getJSPostID(); <--- Returns a string "<?php echo $post_id; ?>"
Thanks
Fred
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Show $post_id via javascript function’ is closed to new replies.