Skip to content

Instantly share code, notes, and snippets.

@obiPlabon
Last active January 18, 2018 17:46
Show Gist options
  • Select an option

  • Save obiPlabon/91484a13841acd02707949e47513735e to your computer and use it in GitHub Desktop.

Select an option

Save obiPlabon/91484a13841acd02707949e47513735e to your computer and use it in GitHub Desktop.
Use this condition if you wanna do anything only on static home page
<?php
function op_register_metaboxes( $options ) {
$options = array();
if ( 'page' === get_option( 'show_on_front' )
&& ( $page_id = get_option( 'page_on_front' ) )
&& isset( $_GET['post'] )
&& $_GET['post'] === $page_id ) {
$options[] = array(
'id' => 'op_home_page_only_metabox',
'title' => 'Page Settings',
'post_type' => 'page',
'context' => 'normal',
'priority' => 'high',
'sections' => array(
// Sections config goes here
),
)
}
return $options;
}
add_filter( 'cs_metabox_options', 'op_register_metaboxes' );
<?php
if ( 'page' === get_option( 'show_on_front' )
&& ( $page_id = get_option( 'page_on_front' ) )
&& isset( $_GET['post'] )
&& $_GET['post'] === $page_id ) {
// do your stuffs here
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment