How to use a custom wordpress page?

Asked

Viewed 31 times

1

I am creating a site in wordpress, I have some templates already ready as: index.php, Category.php, 404.php, single.php.

I created a custom "blog.php" page and directed a link to it with:

href="<?php echo esc_url( home_url( '/blog.php' ) ); ?>"

It tells me the page doesn’t exist.

  • Are they outside wordpress? If yes he is probably looking for that file blog.php in the root folder where the wordpress index is

  • is in the index folder.php yes

  • With so little information you can’t really know what’s going on. You tried to access the route directly through the url? seusite/blog.php ?

  • I’m assembling the structure yet, what other information do you need? Yes I’ve tried, not found too.

  • Hello, Matheus, can you give us some more information on the context and use case? I’m assuming you’re trying to create a custom template for when the visitor accesses www.exemplo.net/blog/ and 2) that this page will show the latest post. Am I right? template hierarchy and this interactive chart of the hierarchy.?

1 answer

0

Come on, what you should do is create a page template:

  • Open your blog.php file and on the line then <?php you add:

    /* Template name: Blog */

inserir a descrição da imagem aqui

Done that,

  • Create a page in Wordpress > Page
  • In the "Page attributes" option you define it as your template.

inserir a descrição da imagem aqui

Final example:

inserir a descrição da imagem aqui

NOTE: don’t forget to import your header and footer.

Browser other questions tagged

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