Skip to content

Instantly share code, notes, and snippets.

@RichardNesbitt
Created March 26, 2020 20:01
Show Gist options
  • Save RichardNesbitt/05a863da93f183399dd34e7522f26067 to your computer and use it in GitHub Desktop.
Save RichardNesbitt/05a863da93f183399dd34e7522f26067 to your computer and use it in GitHub Desktop.
Custom COVID-19 Header managed in WPBakery Page Builder (formerly Visual Composer)
/*
* place this just inside your theme's <header> tag,
* or above the header and menus if you're theme isn't following proper html5 recommendations
*
* I used CPTUI to create a custom post type of 'COVID-19 Header',
* and then enabled the post type in WPBakery Page Builder > Role Manager
*
* Grab the 'post_id' of the post you create, and use it in the code below
*
* You'll need to give your block elements class names, and write your own CSS. 'Design Tab' settings won't work.
* Only inline styles will carry over.
*/
<div id="Before_header">
<?php
$post = get_post(25569); // specific post
$the_content = apply_filters('the_content', $post->post_content);
if ( !empty($the_content) ) {
echo $the_content;
}
wp_reset_postdata(); //if you forget this, all your pages will show the title of this post
?>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment