WordPress.org

Support

Support » How-To and Troubleshooting » Hook for entire post

Hook for entire post

  • I really need to figure out if there is a hook for an entire post… I can’t find any. I need more than just the content hook… 🙁

Viewing 6 replies - 1 through 6 (of 6 total)
  • Define “more”.

    In other words, an “entry” comes with more than content. It comes with everything in “the loop” on a per entry basis — author name, time of post, permalink, comments link, etc. Essentially, I want to “capture” the entire entry for filtering…

    Everything in the $post object of the loop.

    Moderator Scott Reilly

    @coffee2code

    WordPress & Plugin Developer

    Did you peruse the Plugin API at codex? http://codex.wordpress.org/Plugin_API

    yeah, the closest thing I saw was publish_post and I don’t think that’s the answer…

    Action hooks such as publish_post take the id of the post as a parameter. Once you have the id, you can easily get everything else about the post…

    function foo($post_ID = 129) {
    $data = get_postdata($post_ID);
    print_r($data);
    }

    that should output something to the effect of:

    Array
    (
    [ID] => 129
    [Author_ID] => 1
    [Date] => 2005-06-13 16:45:57
    [Content] => post content here…
    [Excerpt] =>
    [Title] => Boiled Dogs
    [Category] => 0
    [post_status] => publish
    [comment_status] => open
    [ping_status] => open
    [post_password] =>
    [to_ping] =>
    [pinged] =>
    [post_name] => boiled-dogs
    )
    as far as permalinks, etc…. Once you have the id of the post, you can get any other information easily… Everything is just a function call/database query away… All the above information can be used to make the permalink.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Hook for entire post’ is closed to new replies.
Skip to toolbar