Page attribute, template, in a wordpress "project"

0

I have a website in Wordpress, of which some pages I use instead of the wordpress editor, file .php with a Template Name , so I point to the wordpress template, located in page attributes.

But on this site, I also use the "projects" part to create the portfolio, in general all follow a basic pattern set up directly in wordpress with the divi editor, however some specific projects are a bit more worked on page, one of them do several things in php same, css animations, js, svg, among other things. I made a preview of the page already in a .php file with a template name, but I noticed that for projects it does not have this Atributos da Página .

Is there any way to make a specific project take a .php file instead of just being mounted directly in the wordpress editor?

Thank you.

    
asked by anonymous 05.01.2017 / 21:10

1 answer

1

The "Page Attributes" box only exists for Hierarchical Post Types, and your Projects should not be.

In this case you can rename the PHP file and change the Hierarchy of Templates to your advantage.

Example: if the project URL is example.com/project/project_name, you can do:

add_filter( 'template_include', 'redireciona_projeto' );
function redireciona_projeto( $template ) {
    global $post;
    if ( 'nome-do-projeto' == $post->post_name ) {
        $novotemplate = locate_template( array( 'nome-do-arquivo.php' ) );
        if ( '' != $novotemplate ) {
            return $novotemplate ;
        }
    }
    return $template;
}
    
08.01.2017 / 19:02