I’m including the next code to the top of my features.php file to populate a taxonomy based mostly on a Customized submit’s post-title. The issue is that after I add the code I get the next error attempting to login on wp-admin. Any assist determining why that is taking place is vastly appreciated.
Error:
Error: Cookies are blocked resulting from sudden output. For assist, please see this documentation or attempt the assist boards.
Code:
<?php
perform update_custom_terms($post_id) {
// solely replace phrases if it is a 'artist' submit
if ( 'artist' != get_post_type($post_id)) {
return;
// do not create or replace phrases for system generated posts
if (get_post_status($post_id) == 'auto-draft') {
return;
}
$term_title = get_the_title($post_id);
$term_slug = get_post( $post_id )->post_name;
/*
* Test if a corresponding time period already exists by evaluating
* the submit ID to all present time period descriptions.
'artists' is the taxonomy getting populated
*/
$existing_terms = get_terms('artists', array('hide_empty' => false));
foreach($existing_terms as $time period) {
if ($term->description == $post_id) {
//time period already exists, so replace it and we're completed
wp_update_term($term->term_id, 'artists', array(
'identify' => $term_title,
'slug' => $term_slug
)
);
return;
}
}
/*
* If we did not discover a match above, it is a new submit,
* so create a brand new time period.
*/
wp_insert_term($term_title, 'artists', array(
'slug' => $term_slug,
'description' => $post_id
)
);
}
//run the replace perform at any time when a submit is created or edited
add_action('save_post', 'update_custom_terms');
perform delete_term( $post_id ) {
$submit = get_post( $post_id );
if ( time period exists( $post->post_title, 'artists' ) ) {
$time period = get_term_by( 'identify', $post->post_title, 'artists' );
wp_delete_term( $term->term_id, 'artists' );
}
}
add_action( 'before_delete_post', 'delete_term' );
?>