Add private status to function
-
I have this piece of code and it works great.
I can create a shortcut like so ..
https://mysite.net/site/wp-admin/post-new.php?post_title=Journal&category=JournalAnd it sets the title to journal and category to journal.
function set_category () { global $post; //Check for a category parameter in our URL, and sanitize it as a string $category_slug = filter_input(INPUT_GET, 'category', FILTER_SANITIZE_STRING, array("options" => array("default" => 0))); //If we've got a category by that name, set the post terms for it if ( $category = get_category_by_slug($category_slug) ) { wp_set_post_terms( $post->ID, array($category->term_id), 'category' ); } } //hook it into our post-new.php specific action hook add_action( 'admin_head-post-new.php', 'set_category', 10, 1 );
But I would also like to set the post status to private. The thing is not for every category.
I would like to set the post to private only when I use the link to set the category. If this is too much or cant be done .. i dont mind hard coding the Journal in there or something.
thanks for your help
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Add private status to function’ is closed to new replies.