Skip to content

Instantly share code, notes, and snippets.

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 Oscar-Abad-Folgueira/ebc85aac65319ba3605b156c87a60c2a to your computer and use it in GitHub Desktop.
Save Oscar-Abad-Folgueira/ebc85aac65319ba3605b156c87a60c2a to your computer and use it in GitHub Desktop.
WordPress Snippet: Establecer un single de un CPT como página de inicio.
<?php
/**
* @snippet WordPress Snippet: Establecer un single de un CPT como página de inicio.
* @author Oscar Abad Folgueira
* @author_url https://www.oscarabadfolgueira.com
* @snippet_url https://oscarabadfolgueira.com/establecer-un-single-de-un-cpt-como-pagina-de-inicio/
*/
function add_pages_to_dropdown( $pages, $r ){
if ( ! isset( $r[ 'name' ] ) )
return $pages;
if ( 'page_on_front' == $r[ 'name' ] ) {
$args = array(
'post_type' => 'micpt'
);
$micpt = get_posts( $args );
$pages = array_merge( $pages, $micpt );
}
return $pages;
}
add_filter( 'get_pages', 'add_pages_to_dropdown', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment