User Tools

Site Tools


components-depending-on-the_page

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
components-depending-on-the_page [2017/02/28 00:47]
Timbow
components-depending-on-the_page [2017/02/28 00:56]
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//, + 
-  ​**otherwise if** the page slug is //about// insert the component //paul// +>**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//. 
-  ​and **otherwise** just insert the component //mary//.+
  
  
components-depending-on-the_page.txt · Last modified: 2017/02/28 00:56 by Timbow