WordPress.org

Ready to get started?Download WordPress

Forums

Post Categories and the publish_post hook (6 posts)

  1. TechGnome
    Moderator
    Posted 9 years ago #

    OK, for those who haven't heard, I've been working on a plugin for 1.2 that will help mimic "static" pages in WP. What I've done is in the write post page, added an additional check box at the bottom of the categories listing called "Make Static". When the post is published, if this box is marked, I want to set the catID for the post to -1. So... I wrote the plugin to hook into edit_post and publish_post events so that when it's either published or edited and saved, it will check for flag and reset the category id if necessary.
    Here's the bit I seem to be having a problem with. If I create post (this is from the advanced screen) click the "Make Static" check box and hit the "Publish" button.... it doesn't work. BUT, if I then edit the post, reclick the Make Static, then press the Save button, the change will take.
    I've checked my code, I don't seem to be doing anything wrong. I've checked the code where the hook is called from, it's very clearly after the category IDs are saved, so it should work. I just don't know why not. Does any one else have any ideas?
    TG

  2. AaronLawrence
    Member
    Posted 9 years ago #

    There is a plugin by the name of adhesive (it makes posts sticky) that has the exact same problem as you. As of yet the webmaster has not solved the issue. As long as you're aware of the limitation though you can work around it, as inconvienent and inelegant as that is. But at least one can get the function to work.

  3. TechGnome
    Moderator
    Posted 9 years ago #

    hrmmm..... that would explain that.... I uh... used Adhesive as a template because it did something similar to what I was trying to do.... gah! The deal is, it *shouldn't* be doing this..... I've looked at the posting code, and I can quite clearly see that the filter should be getting called after the post cats are saved....
    Hrrmmmmm........
    *back to the drawing board*
    TG

  4. Beel
    Member
    Posted 9 years ago #

    TG - Have you checked out what 1.3 is going to have?

  5. TechGnome
    Moderator
    Posted 9 years ago #

    Beel -- yes.... this is a stop gap in the mean time..... until 1.3 is ready for prime time, I wanted something else. Once 1.3 has been officialy released and others have banged on it for a while (Mingus was out 2 months before I moved to it) and the major problems have been worked out, then I'll upgrade and use the new "static" page architecture.
    In the meantime, is there any documentation on how this new feature is going to work?
    TG

  6. TechGnome
    Moderator
    Posted 9 years ago #

    Hoo-Ha! I got the problem fixed. The key was in the priority setting of the publish-post hook. I had it set to a higher priority (8 I think)... I found another plugin that was using the same hook and noticed that it had a priority of 6, so I changed mine to the same, and viola! It works! Woo-hooo!
    Look for the plugin to be available soon!
    TG

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.