Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the easy-digital-downloads domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/danigirol0/www/wp-includes/functions.php on line 6260

Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the wordpress-seo domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/danigirol0/www/wp-includes/functions.php on line 6260

Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the metform domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/danigirol0/www/wp-includes/functions.php on line 6260
Crear una pagina vacia desde un plugin en wordpress. Registrarla y pone un template - Dani Girol

Crear una pagina vacia desde un plugin en wordpress. Registrarla y pone un template

add_filter( 'page_template', 'wpa3396_page_template' );
function wpa3396_page_template( $page_template )
{
    if ( is_page( 'my-custom-page-slug22' ) ) {
		echo 'Entra por aqui';
        $page_template = dirname( __FILE__ ) . '/template-api.php';
    }
    return $page_template;
}

register_activation_hook( __FILE__, 'installar' );
function installar(){

    $titulo = 'my-custom-page-slug22';
    $descripcion = 'Pagina reservada para la api';
    $plantilla = ''; // Ej. plantilla-contacto.php. Dejar en blanco si quieres dejar la plantilla de por defecto.
    //don't change the code bellow, unless you know what you're doing
    $page_check = get_page_by_title($titulo);
    $new_page = array(
        'post_type' => 'page',
        'post_title' => $titulo,
        'post_content' => $descripcion,
        'post_status' => 'publish',
        'post_author' => 1,
    );
    if(!isset($page_check->ID)){
        $new_page_id = wp_insert_post($new_page);
        if(!empty($plantilla)){
            update_post_meta($new_page_id, '_wp_page_template', $plantilla);
        }
    }
    

}