WordPress.org

Ready to get started?Download WordPress

Forums

Set post status based on taxonomy (1 post)

  1. isay
    Member
    Posted 2 years ago #

    Hi there!

    I'd like to set post status based on if a post belongs to a specific taxonomy...

    I have a site where I let users create posts (custom post type "event") from front-end. The users can create posts and associate them with a category and a "channel" taxonomy. The users can create "real" posts and "test" posts. For this I created a "Test Channel". From front-end you can navigate among the posts based on category, channel etc. I want to prevent all "test" posts from appearing in any other place than one specific place, ie when I view the "Test Channel"...

    The only way I managed to do this was by creating a new post status "test-post", which is hidden in all places except in the "Test Channel"-page. So far so good...

    Now what I needed to do was to set the status based on taxonomy. I used the "save_post" action hook for this, which checks the taxonomy and sets the status...

    This works fine when I do update of posts, since I can do update of the taxonomy before doing update of the post. The problem is when I create a new post! When creating a new post I need to create the post before associating the taxonomy. Thus the "save_post" action hook is unaware of the "Test Channel" taxonomy when doing the update of the status...

    Any tips on how to solve this or doing something alternative?

    Cheers,
    Mike

Topic Closed

This topic has been closed to new replies.

About this Topic