РЕДАКТИРОВАТЬ:
Если вы хотите добавить контент только в функцию the_content, вы можете сделать что-то вроде этого:
add_filter('the_content', "test_the_content");
function test_the_content($content){
if(is_singular('test')){
$content = $content.test_additional_content();
}
return $content;
}
function test_additional_content(){
ob_start(); ?>
<div class="test">
Here what you want to display after the_content
</div>
<?php
return ob_get_clean();
}
ОРИГИНАЛЬНЫЙ ОТВЕТ
Если я понял ваш вопросправильно, вот как определить шаблоны вашего пользовательского типа сообщения в вашем плагине. Таким образом, также будет возможно перезаписать шаблон плагина из темы.
Пример ниже для CPT, называемого «test», поэтому вы должны адаптировать код в соответствии с именем вашего CPT.
add_filter('template_include', 'my_plugin_templates');
function my_plugin_templates($template) {
$post_types = array('test');
if (is_post_type_archive($post_types) && !file_exists(get_stylesheet_directory() . '/archive-test.php')) {
$template = plugin_dir_path( __FILE__ ) . 'archive-test.php';
}
if (is_singular($post_types) && !file_exists(get_stylesheet_directory() . '/single-test.php')) {
$template = plugin_dir_path(__FILE__) . 'single-test.php';
}
return $template;
}
Вы также можете посмотреть этот репо: https://github.com/zecka/cpt-in-plugin