Add singular page in WordPress plugin

<?php function load_movie_template( $template ) { global $post; if ( 'movie' === $post->post_type && locate_template( array( 'single-movie.php' ) ) !== $template ) { /* * This is a 'movie' post * AND a 'single movie template' is not found on * theme or child theme directories, so load it * from our plugin directory. */ return plugin_dir_path( __FILE__ ) . 'single-movie.php'; } return $template; } add_filter( 'single_template', 'load_movie_template' ); ?>

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.