Get Page or Post ID from JavaScript (2 posts)

  1. eloyrubio
    Posted 3 years ago #

    I want to get a Post id from a javascript function in the post editor. I tried this code, but does not work for me:

    function get_post_content(){
       return document.getElementById("post-"+id).innerHTML;
    <a href="#" onclick="get_post_content(<?php the_ID(); ?>);">Next</a>

    Thank you in advance.

  2. KajMagnus
    Posted 3 years ago #

    You haven't included any parameter in get_post_content(){ ...;
    this should work better: get_post_content(id){ ...

Topic Closed

This topic has been closed to new replies.

About this Topic