Skip to content

Instantly share code, notes, and snippets.

@imran-khan1
Last active July 3, 2019 11:19
Show Gist options
  • Save imran-khan1/2671a506c5f4a254d4667bf32ad83533 to your computer and use it in GitHub Desktop.
Save imran-khan1/2671a506c5f4a254d4667bf32ad83533 to your computer and use it in GitHub Desktop.
<?php
function wcik_add_page_template ($templates) {
$templates['archive-manufacturer.php'] = 'Manufacturer';
return $templates;
}
add_filter ('theme_page_templates', 'wcik_add_page_template');
function wcik_archive_page_template ($template) {
if (is_page_template('archive-manufacturer.php')){
$template = plugin_dir_path( __FILE__ ) . 'templates/manufacturer/archive-manufacturer.php';
}
return $template;
}
add_filter ('page_template', 'wcik_archive_page_template');
function wcik_single_page_template($single_template) {
global $post;
if ($post->post_type == 'manufacturer') {
$single_template = plugin_dir_path( __FILE__ ) . 'templates/manufacturer/single-manufacturer.php';
}
return $single_template;
}
add_filter( 'single_template', 'wcik_single_page_template' );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment