This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | Last revision Both sides next revision | ||
components-depending-on-the_page [2017/02/28 00:47] Timbow |
components-depending-on-the_page [2017/02/28 00:50] Timbow [Several Pages Each with Different Components] |
||
---|---|---|---|
Line 7: | Line 7: | ||
=====Several Pages Each with Different Components===== | =====Several Pages Each with Different Components===== | ||
- | Say you have three pages with the slugs //index//, //about//, //contact// and sidebars as components named //peter//, //paul// and //mary// you would edit your template to replace **<?php get_component(sidebar); ?>** with | + | Say you have three pages with the slugs //index//, //about//, //contact// and sidebars as components named //peter//, //paul// and //mary// you would edit your template to replace <code><?php get_component(sidebar); ?></code> with |
<code> | <code> | ||
<?php if (return_page_slug()=='index') {get_component('peter');} | <?php if (return_page_slug()=='index') {get_component('peter');} | ||
Line 13: | Line 13: | ||
else {get_component('mary');} ?> </code> | else {get_component('mary');} ?> </code> | ||
which in English reads | which in English reads | ||
- | *If** the page slug is //index// insert the component //peter//, | + | **If** the page slug is //index// insert the component //peter//, **otherwise if** the page slug is //about// insert the component //paul// and **otherwise** just insert the component //mary//. |
- | **otherwise if** the page slug is //about// insert the component //paul// | + | |
- | and **otherwise** just insert the component //mary//. | + | |