WordPress.org

Ready to get started?Download WordPress

Forums

How to get post id in the_content type filter (5 posts)

  1. are79
    Member
    Posted 6 years ago #

    I am trying to get post id in a the_content filter. How to do this in a proper way. Thank you ...

  2. Kafkaesqui

    Posted 6 years ago #

    ?

    I'm not sure I understand how the filter for post content relates to a post's ID. Actually, it doesn't. So, please explain the results you're after. You just want to collect the ID for a post?

  3. are79
    Member
    Posted 6 years ago #

    I have some home made markup tags in the post and i use the_content filter to replace those tags with some content which is associated with being filtered post and stored in a mysql table. I used to use global $post,$post_ID; But now it stopped to function for some reason. Maybe it is better to use some other hook, not the _content to deal with this ?

  4. Kafkaesqui

    Posted 6 years ago #

    Scoping $post to global should then make everything in the post object available:

    global $post;

    The ID can be accessed through $post->ID

  5. yakuphan
    Member
    Posted 6 years ago #

    That is so cool. It is really usefull. Thanks...

Topic Closed

This topic has been closed to new replies.

About this Topic