ソースを参照

Only apply negative margins to these blocks when page titles are hidden

Ben Dwyer 4 年 前
コミット
3a3cce37c7

+ 8 - 8
blank-canvas/style.css

@@ -58,14 +58,14 @@ Used as block pattern image.
 
 /* Remove some top padding if the first block on the page is a full-width image, cover, media & text, or group block. */
 
-.single .entry-content > .wp-block-image.alignfull:first-child,
-.page .entry-content > .wp-block-image.alignfull:first-child,
-.single .entry-content > .wp-block-cover.alignfull:first-child,
-.page .entry-content > .wp-block-cover.alignfull:first-child,
-.single .entry-content > .wp-block-media-text.alignfull:first-child,
-.page .entry-content > .wp-block-media-text.alignfull:first-child,
-.single .entry-content > .wp-block-group.has-background.alignfull:first-child,
-.page .entry-content > .wp-block-group.has-background.alignfull:first-child {
+.single .entry-content.hide-post-and-page-titles > .wp-block-image.alignfull:first-child,
+.page .entry-content.hide-post-and-page-titles > .wp-block-image.alignfull:first-child,
+.single .entry-content.hide-post-and-page-titles > .wp-block-cover.alignfull:first-child,
+.page .entry-content.hide-post-and-page-titles > .wp-block-cover.alignfull:first-child,
+.single .entry-content.hide-post-and-page-titles > .wp-block-media-text.alignfull:first-child,
+.page .entry-content.hide-post-and-page-titles > .wp-block-media-text.alignfull:first-child,
+.single .entry-content.hide-post-and-page-titles > .wp-block-group.has-background.alignfull:first-child,
+.page .entry-content.hide-post-and-page-titles > .wp-block-group.has-background.alignfull:first-child {
 	margin-top: calc(-1 * var(--global--spacing-vertical));
 }
 

+ 7 - 2
blank-canvas/template-parts/content/content-singular.php

@@ -8,10 +8,11 @@
  * @since 1.0
  */
 
+$show_post_and_page_titles = get_theme_mod( 'show_post_and_page_titles', false );
 ?>
 
 <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
-	<?php if ( true === get_theme_mod( 'show_post_and_page_titles', false ) ) : ?>
+	<?php if ( $show_post_and_page_titles ) : ?>
 		<header class="entry-header default-max-width">
 			<?php
 			if ( is_singular() ) :
@@ -25,7 +26,11 @@
 
 	<?php seedlet_post_thumbnail(); ?>
 
-	<div class="entry-content">
+	<div class="entry-content
+	<?php
+	if ( ! $show_post_and_page_titles ) :
+		?>
+		hide-post-and-page-titles<?php endif; ?>">
 		<?php
 		the_content(
 			sprintf(