Skip to content

Commit

Permalink
Add missing piece for post-meta to tax refactor (#27042)
Browse files Browse the repository at this point in the history
  • Loading branch information
aristath authored and david-szabo97 committed Nov 17, 2020
1 parent 45cfc66 commit 739927f
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/templates.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,15 @@ function gutenberg_set_template_post_theme( $post_id, $post, $update ) {
return;
}

$theme = get_post_meta( $post_id, 'theme', true );
$wp_theme_term = get_term_by( 'slug', wp_get_theme()->get_stylesheet(), 'wp_theme' );
if ( $wp_theme_term ) {

if ( ! $theme ) {
update_post_meta( $post_id, 'theme', wp_get_theme()->get_stylesheet() );
// If the term was found, assign it to this post.
wp_set_object_terms( $post_id, $wp_theme_term->term_id, 'wp_theme' );
} else {

// Using a string instead of integer will create the term and assign it to the post.
wp_set_object_terms( $post_id, wp_get_theme()->get_stylesheet(), 'wp_theme' );
}
}

Expand Down

0 comments on commit 739927f

Please sign in to comment.