Support » Fixing WordPress » Retrieve Post ID from Body Class with Javascript

  • Resolved lozbo

    (@lozbo)


    I have this html outcome:

    <body class="single single-post postid-1489 single-format-standard inner-page" >

    And I want to get the post ID number (only the number, without “postid-“) with JavaScript.

    This is as close as I’ve gotten:

    document.body.(class*=' postid-').value

    But I’m afraid its not getting the job done.

    I found this thread:

    http://wordpress.org/support/topic/post-id-in-javascript?replies=7

    But it’s not really what I’m looking for.

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Retrieve Post ID from Body Class with Javascript’ is closed to new replies.