Last active
October 11, 2022 11:21
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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