Change post category when a comment is posted
-
Howdy!
I modified my WordPress comment section to show only a button (Book!) that posts a prewritten comment (I’m booking this):
<?php if (in_category( 'available' )) : ?> <?php if ( comments_open() ) { comment_form(array( 'title_reply'=>'', 'label_submit' => esc_html__( 'Book!' ), 'comment_field' => '<textarea id="comment" name="comment" cols="45" rows="5" maxlength="65525" required="" style="display:none">'. __('I'm booking this.','textdomain').'</textarea>', )); } ?> <?php endif;?>
Now: when the first comment has ben posted I would like the category of the post to change from ‘available’ to ‘booked’… I’m guessing I should use something like this:
wp_set_object_terms( $post_id, $category, 'booked' );
But where and how do I put that piece of code into action…? ??
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Change post category when a comment is posted’ is closed to new replies.