How to customize only one type of post to appear in single.php

0

I'm developing a wordpress jobs plugin, I picked up as wpjobmanager base is coming out all right, until I come across the following, the plugin when the user clicks to see more about the particular job opens the single.php however he It's difficult to explain, the single php will contain the wordpress loop that will show the content of that post, but this plugin can only customize their post. I thought about changing the single to suit the plugin but that would be wrong because it would have to modify the theme, and the idea of the plugin is to pick up on any theme.

Example of what the plugin does:

    
asked by anonymous 07.03.2018 / 13:59

1 answer

3

According to the documentation here , you can create a new single with the name within the current theme .

single-<post-type>.php

If you use post type

single-emprego.php

For a change from the plugin, you can use

add_filter('template_include', 'meu_single_personalizado');
function meu_single_personalizado( $template ) {

    if (is_singular("emprego")) {
        $template = 'caminho/no/plugin/para/o/single.php';
    }

    return $template;
}

as seen in this answer

    
07.03.2018 / 17:07