Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

missing piece for post-meta to tax refactor #27042

Merged
merged 1 commit into from
Nov 17, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions lib/templates.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,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