Skip to content

Instantly share code, notes, and snippets.

@dartiss
Last active March 25, 2018 15:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dartiss/045b5c0aa06ab6d16b21226e63164704 to your computer and use it in GitHub Desktop.
Save dartiss/045b5c0aa06ab6d16b21226e63164704 to your computer and use it in GitHub Desktop.
Add Gutenberg promo to the site of WordPress posts
<?php
function add_gutenberg_promo( $content ) {
global $post;
if ( function_exists( 'gutenberg_post_has_blocks' ) && gutenberg_post_has_blocks( $post->ID ) && is_single() ) {
$content = '<div style="background:#fff8c4; border:1px solid #f2c779; border-radius:10px; padding:10px; margin-bottom:10px;">This post was created using Gutenberg, the new editor, coming soon, for WordPress. You can <a href="https://wordpress.org/gutenberg/">learn more about it here</a>, <a href="https://wordpress.org/plugins/gutenberg/">try the Beta plugin</a> or simply <a href="https://testgutenberg.com">try it out for yourself</a>, no site required.</div>' . $content;
}
return $content;
}
add_filter( 'the_content', 'add_gutenberg_promo' );
@dartiss
Copy link
Author

dartiss commented Mar 25, 2018

Add to your theme's functions.php file to add a promotional message about Gutenberg to the top of your posts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment