Skip to content

Instantly share code, notes, and snippets.

@alinademi
Forked from mikeott/close-yoast-metabox.php
Last active January 10, 2023 05:41
Show Gist options
  • Save alinademi/e37b661f67ceaf0061ea6dc088b4a5ab to your computer and use it in GitHub Desktop.
Save alinademi/e37b661f67ceaf0061ea6dc088b4a5ab to your computer and use it in GitHub Desktop.
Force the Yoast metabox to be closed by default.
function collapse_yoast_matabox()
{
if (!class_exists('WPSEO_Metabox')) {
return;
}
echo /*html*/ '
<script>
document.addEventListener("DOMContentLoaded",
function(event) {
document.querySelector(".yoast.wpseo-metabox").classList.add("closed");
});
</script>';
}
add_action('admin_head', 'collapse_yoast_matabox');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment