Page with different layout

0

I'm starting to develop themes for WordPress and until then I got some content and tutorials on how to do such thing, however the information I have is that:

  • page.php page is responsible for displaying site pages such as contato , quem somos and etc.
  • and the single.php page is responsible for displaying the contents of the points along with the archive.php page.

One of the doubts is exactly this, what is the judgment system for WordPress to use the pages single and archive ? The other question is how can I apply different styles to different pages? If the content of (contato, quem somos) pages is displayed in page.php that contains only 1 style?

    
asked by anonymous 09.10.2015 / 14:26

2 answers

1

One way to apply individual styles, for example in the Contact page, is to create a page-contato.php template. The important thing is slug of the page:

Ifthatslugwassample-page,thetemplatewouldhavetobecalledpage-sample-page.php.

Andwhenediting,itmakestherequiredCSSmarkuponthiscustomtemplate.

Anotherverysimplewayisifyouhave body_class() applied to <body> of HTML. This is in the file header.php :

</head>   
<body <?php body_class(); ?>>
<div id="conteudo">

With this function applied to <body> , the HTML for the contact page is as follows:


And in your stylesheet, you would apply rules like:

body.page-id-2 #conteudo { text-align: right }

This way you can customize virtually all pages, posts, categories, etc.

You can check out more documentation , which includes this diagram of how the template hierarchy works in WordPress:

    
10.10.2015 / 01:23
0

Regarding the criterion ... Ideally, you should read the documentation of hierarchy in the codex . > For you to create different styles for pages you can create a Page Template.
With it you will can do different styles, have different singles, archive, header, footer and etc. Home It is idela you see in the codex about. And before you create the Page Templete, the ideal is for you to have the WP hierarchy clear in your head or to try to get the most out of it. Do not bring trouble in the future.
I hope I have helped.
See you.

    
10.10.2015 / 00:19