2. Hello 9.00 - 9.15
1 An introduction to WordPress 09.15 - 09.30
2 The core components of a theme 09.30 - 10.00
3 Using WordPress as a proper CMS 10.00 - 10.30
Morning tea 10.30 - 11.00
4 A portfolio powered by WordPress 11.00 - 11.30
5 Building a brand new theme 11.30 - 12.00
Q&A / discussion 12.00 - 12.30
24. Say it in English
What am I trying to accomplish?
If a certain situation occurs, do X;
if it doesn’t occur, do Y
What’s the easiest way to accomplish this?
25. START.
If the page slug is 'design-network',
use the word ‘Design’ as my network name;
but if the page slug is 'photography-network',
use the word ‘Photography’ as my network name;
or, if it’s neither of those,
just use the word ‘Default’ as my network name.
END.
Think of things in plain English
26. <?php
if (is_page('design-network')) {
$network="Design";
} elseif (is_page('photography-network')) {
$network="Photography";
} else { // default
$network="Default";
}
?>
Set up a variable you can use later on
27. <h2>
Fusion Ads delivered <strong>17,737,824</strong>
ad impressions in July across its dedicated
<strong>Design</strong> network
</h2>
Set up a variable you can use later on
28. <h2>
Fusion Ads delivered <strong>17,737,824</strong>
ad impressions in July across its dedicated
<strong>PUT_THE_NETWORK_NAME_HERE</strong> network
</h2>
Set up a variable you can use later on
29. <h2>
Fusion Ads delivered <strong>17,737,824</strong>
ad impressions in July across its dedicated
<strong><?php echo $network; ?></strong> network
</h2>
Set up a variable you can use later on
30. START.
If the page is the ‘home’ page,
use the word ‘home’ as my body’s classname;
but if it’s in the ‘portfolio’ category,
use the word ‘portfolio’ as my body’s classname;
unless it’s in the ‘speaking’ category,
then use the word ‘speaking’ as my body’s classname;
or if it’s the ‘publication’ page,
use the word ‘publication’ as my body’s classname;
but if it’s a 404 or search results page,
use the word ‘results’ as my body’s classname;
or if it’s none of the above,
just use the word ‘default’ as my body’s classname.
END.
Set up a variable you can use later on
31. <?php
if (is_home()) { // Home
$bodyclass="home";
} elseif (is_category('portfolio')) { // Portfolio
$bodyclass="portfolio";
} elseif (is_category('speaking')) { // Speaking
$bodyclass="speaking";
} elseif (is_page('publication')) { // publication
$bodyclass="publication";
} elseif (is_404() || is_search()) { // 404 or search
$bodyclass="nothing";
} else { // default
$bodyclass="blog";
}
?>
Set up a variable you can use later on
32. is_home
<?php
if (is_home()) { // Home
$bodyclass="home";
} elseif (is_category('portfolio')) { // Portfolio
$bodyclass="portfolio";
} elseif (is_category('speaking')) { // Speaking
$bodyclass="speaking";
} elseif (is_page('publication')) { // publication
$bodyclass="publication";
} elseif (is_404() || is_search()) { // 404 or search
$bodyclass="nothing";
} else { // default
$bodyclass="blog";
}
?>
Set up a variable you can use later on
33. is_category
<?php
if (is_home()) { // Home
$bodyclass="home";
} elseif (is_category('portfolio')) { // Portfolio
$bodyclass="portfolio";
} elseif (is_category('speaking')) { // Speaking
$bodyclass="speaking";
} elseif (is_page('publication')) { // publication
$bodyclass="publication";
} elseif (is_404() || is_search()) { // 404 or search
$bodyclass="nothing";
} else { // default
$bodyclass="blog";
}
?>
Set up a variable you can use later on
34. is_page
<?php
if (is_home()) { // Home
$bodyclass="home";
} elseif (is_category('portfolio')) { // Portfolio
$bodyclass="portfolio";
} elseif (is_category('speaking')) { // Speaking
$bodyclass="speaking";
} elseif (is_page('publication')) { // publication
$bodyclass="publication";
} elseif (is_404() || is_search()) { // 404 or search
$bodyclass="nothing";
} else { // default
$bodyclass="blog";
}
?>
Set up a variable you can use later on
35. is_404() || is_search
<?php
if (is_home()) { // Home
$bodyclass="home";
} elseif (is_category('portfolio')) { // Portfolio
$bodyclass="portfolio";
} elseif (is_category('speaking')) { // Speaking
$bodyclass="speaking";
} elseif (is_page('publication')) { // publication
$bodyclass="publication";
} elseif (is_404() || is_search()) { // 404 or search
$bodyclass="nothing";
} else { // default
$bodyclass="blog";
}
?>
Set up a variable you can use later on
42. <li class="blog">
<a href="http://elliotjaystocks.com/blog/">
Blog
</a>
</li>
<li class="portfolio">
<a href="http://elliotjaystocks.com/portfolio/">
Portfolio
</a>
</li>
<li class="speaking">
<a href="http://elliotjaystocks.com/speaking/">
Speaking
</a>
</li>
Set up a variable you can use later on
43. <li class="blog">
<a href="<?php bloginfo('url'); ?>/blog/">
Blog
</a>
</li>
<li class="portfolio">
<a href="<?php bloginfo('url'); ?>/portfolio/">
Portfolio
</a>
</li>
<li class="speaking">
<a href="<?php bloginfo('url'); ?>/speaking/">
Speaking
</a>
</li>
Set up a variable you can use later on