How to customize only one post type to appear on the single.php

Asked

Viewed 203 times

0

I am developing a job plugin for wordpress, I took as a basis the wpjobmanager 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 but it modifies the way it... Kind of hard to explain, The single php will contain the wordpress loop that will show the content of that post, but this plugin can customize only their post (employment). I thought to change the single to suit the plugin but this would be wrong because I would have to modify the theme, and the idea of the plugin is to pick any theme.

Example of what the plugin does:

inserir a descrição da imagem aqui

1 answer

3


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

single-<post-type>.php

if the post type is used

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 can be seen in this reply

  • Opa thanks for the reply, but unfortunately it does not serve as I can not change the theme, the plugin should work at all

  • @Andersonhenrique I understood this Anderson, so I gave two suggestions to be registered including for future users who search. For use in the plugin you can use the template_include filter, this template is inside your plugin. =)

  • Oops It worked, thank you very much

Browser other questions tagged

You are not signed in. Login or sign up in order to post.