WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] how to detect when a new post is made? (6 posts)

  1. maestro42
    Member
    Posted 6 years ago #

    I want to write a plugin that does something when a new post is made.

    Is there a way to have this plugin detect when a new post is made and then run some function?

    Please let me know if anyone knows!

    Thanks.

  2. whooami
    Member
    Posted 6 years ago #

  3. maestro42
    Member
    Posted 6 years ago #

    thanks whooami!

  4. maestro42
    Member
    Posted 6 years ago #

    this was a great help.

  5. maestro42
    Member
    Posted 6 years ago #

    just a quick question.

    I have a function that gets passed the post_id. So I want to get 2 things, the content and the category.

    I use:

    $usepostid = get_post($post_ID);
             $sendcontent = $usepostid->post_content;

    to get the content - but i saw that post_category doesn't work anymore. It says to use get_post_category() - but only within the loop. How can I get the post category ID outside the loop ?

    Thanks!

  6. maestro42
    Member
    Posted 6 years ago #

    i tried get_the_category() and it worked fine, even outside the Loop

Topic Closed

This topic has been closed to new replies.

About this Topic