/
day2.html
1165 lines (890 loc) · 36.1 KB
/
day2.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>GDI - Building Themes for WordPress</title>
<meta name="description" content="Girl Develop It framework for easily creating beautiful presentations using HTML in GDI theme. Forked from Hakim El Hattab's reveal.js">
<meta name="author" content="Girl Develop It">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<link rel="stylesheet" href="css/reveal.css">
<link rel="stylesheet" href="css/theme/gdilight.css" id="theme">
<!-- For syntax highlighting -->
<!-- light editor<link rel="stylesheet" href="lib/css/light.css">-->
<!-- dark editor--><link rel="stylesheet" href="lib/css/light.css">
<!-- If use the PDF print sheet so students can print slides-->
<link rel="stylesheet" href="css/print/pdf.css" type="text/css" media="print">
<link rel="icon" type="image/x-icon" href="favicon.ico" />
<!--[if lt IE 9]>
<script src="lib/js/html5shiv.js"></script>
<![endif]-->
</head>
<body>
<div class="reveal">
<!-- Any section element inside of this container is displayed as a slide -->
<div class="slides">
<!-- Opening -->
<section id="beginning-slide">
<h3>Girl Develop It</h3>
<h1>Building Themes for WordPress</h1>
<p>
<small>With Tracy Levesque</small>
</p>
<p>
<small><a href="https://twitter.com/LilJimmi" target="_blank">@LilJimmi</a> •
<a href="mailto:tracy@yikesinc.com">tracy@yikesinc.com</a> •
<a href="http://yikesinc.com" target="_blank">yikesinc.com</a></small>
</p>
<p>
Day 2 Slides located at: <a href="http://thetracyl.com/gdi/building-themes/day2.html">thetracyl.com/gdi/building-themes/day2.html</a>
</p>
</section>
<!-- Examples of basic html based slides -->
<section>
<h2>Day 2</h2>
<h3>Today you will...</h3>
<ul>
<li>Learn about loops and queries</li>
<li>Learn about adding functionality to your theme</li>
<li>Learn about hooks, actions and filters</li>
<li>Learn some handy WordPress functions</li>
<li>Learn how to make widgetized areas and widgets</li>
<li>Learn how to make custom post types</li>
</ul>
<h3>And</h3>
<ul>
<li>Take a 15 minute break at 3pm</li>
</ul>
</section>
<!-- Examples of basic html based slides -->
<section>
<h2>But First</h2>
<h3>A review...</h3>
<ul>
<li>What is the #1 rule of WordPress development?</li>
<li>What is the proper method of modifying an existing WordPress theme?</li>
<li>What is a conditional tag?</li>
<li>What is the purpose of the WordPress Template Hierarchy?</li>
<li>What is the benefit of using a Starter Theme?</li>
</ul>
</section>
<section>
<h3>The Loop</h3>
<h4><a href="http://codex.wordpress.org/The_Loop" target="_blank">codex.wordpress.org says:</a></h4>
<blockquote>
The Loop is PHP code used by WordPress to display posts.
</blockquote>
</section>
<section>
<h3>The Loop</h3>
<h4>Runs on Every Page</h4>
<p>
The Loop is a set of instructions in a template that grabs content and displays it on a page.
</p>
<p>
It's called a "loop" because the set of instructions can be repeated multiple times on a page. For example, <code>index.php</code>.
</p>
<p><br />Check out the WordPress Codex <a href="http://codex.wordpress.org/The_Loop" target="_blank">The Loop</a></p>
</section>
<section>
<h3>The Loop</h3>
<h4>What it is</h4>
<p>
Within The Loop are the main parts of a page or post.
</p>
<p><code><?php the_title(); ?></code></p>
<p><code><?php the_content(); ?></code></p>
</section>
<section>
<h3>The Loop</h3>
<h4>What it is</h4>
<p>
You can also grab additional content, aka <strong>Metadata</strong>, attached to pages or posts. Some function tags will only work if they are <a href="http://codex.wordpress.org/Stepping_Into_Template_Tags#Template_Tags_and_The_Loop" target="_blank">placed within The Loop</a>.
</p>
<ul>
<li>Author</li>
<li>Date</li>
<li>Featured Image</li>
<li>Categories (posts only)</li>
<li>Tags (posts only)</li>
<li>Etc.</li>
</ul>
</section>
<section>
<h3>The Loop</h3>
<h4>Examples</h4>
<p>
Let's check out The Loop in a few different Twentythirteen templates
</p>
<ul>
<li><code>page.php</code></li>
<li><code>index.php</code></li>
<li><code>content.php</code></li>
</ul>
</section>
<!-- Examples of basic html based slides -->
<section>
<h2>Exercise time!</h2>
<h3>Practice modifying the WordPress Loop</h3>
<ul>
<li>Make a copy of a template in your child theme and modify the default loop</li>
<li>Suggestion: Remove comments from pages.</li>
</ul>
</section>
<section>
<h3>WP_Query</h3>
<p>Use <code>WP_Query</code> to write your own loops</p>
<p><br />Check out the WordPress Codex <a href="http://codex.wordpress.org/Class_Reference/WP_Query" target="_blank">WP_Query</a></p>
</section>
<section>
<h3>WP_Query</h3>
<h4>Basic Structure</h4>
<pre><code><!-- // The Query -->
<?php $myloop = new WP_Query( $args ); ?>
<ul>
<!-- // The Loop -->
<?php while ($myloop->have_posts()) : $myloop->the_post(); ?>
<li>
<h2><?php the_title(); ?></h2>
<p><?php the_content(); ?></p>
</li>
<?php endwhile; ?>
</ul>
</code></pre>
<p><br />Check out the WordPress Codex <a href="http://codex.wordpress.org/Class_Reference/WP_Query" target="_blank">WP_Query</a></p>
</section>
<section>
<h3>WP_Query</h3>
<h4>$args</h4>
Show posts by a certain author:
<pre><code><!-- // The Query -->
<?php $myloop = new WP_Query( 'author_name=tracy' ); ?>
</code></pre>
<p><br />Check out the WordPress Codex <a href="http://codex.wordpress.org/Class_Reference/WP_Query#Author_Parameters" target="_blank">WP_Query Author Parameters</a></p>
</section>
<section>
<h3>WP_Query</h3>
<h4>$args</h4>
Show posts in a certain category:
<pre><code><!-- // The Query -->
<?php $myloop = new WP_Query( 'cat=4' ); ?>
</code></pre>
<p><br />Check out the WordPress Codex <a href="http://codex.wordpress.org/Class_Reference/WP_Query#Category_Parameters" target="_blank">WP_Query Category Parameters</a></p>
</section>
<section>
<h3>WP_Query</h3>
<h4>$args</h4>
Show posts with a certain tag:
<pre><code><!-- // The Query -->
<?php $myloop = new WP_Query( 'tag=cats' ); ?>
</code></pre>
<p><br />Check out the WordPress Codex <a href="http://codex.wordpress.org/Class_Reference/WP_Query#Tag_Parameters" target="_blank">WP_Query Tag Parameters</a></p>
</section>
<section>
<h3>WP_Query</h3>
<h4>$args</h4>
Show x number of posts at a time:
<pre><code><!-- // The Query -->
<?php $myloop = new WP_Query( 'posts_per_page=5' ); ?>
</code></pre>
<p><br />Check out the WordPress Codex <a href="http://codex.wordpress.org/Class_Reference/WP_Query#Pagination_Parameters" target="_blank">WP_Query Pagination Parameters</a></p>
</section>
<section>
<h3>WP_Query</h3>
<h4>$args</h4>
Order posts in alphabetical order by title:
<pre><code><!-- // The Query -->
<?php $myloop = new WP_Query( 'orderby=title' ); ?>
</code></pre>
<p><br />Check out the WordPress Codex <a href="http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters" target="_blank">WP_Query Orderby Parameters</a></p>
</section>
<section>
<h3>WP_Query</h3>
<h4>$args</h4>
Put multiple parameters in an array:
<pre><code><!-- // The Query -->
<?php $myloop = new WP_Query( array( 'cat' => 'cooking', 'posts_per_page' => '5', 'orderby' => 'date', 'order' => 'DESC' ) ); ?>
<ul>
<!-- // The Loop -->
<?php while ($myloop->have_posts()) : $myloop->the_post(); ?>
<li>
<h2><?php the_title(); ?></h2>
<p><?php the_content(); ?></p>
</li>
<?php endwhile; ?>
<!-- // The end of The Loop -->
</ul>
</code></pre>
</section>
<!-- Examples of basic html based slides -->
<section>
<h2>Exercise time!</h2>
<h3>Make a "Recent Posts" featured content box on the home page</h3>
<ul>
<li>Make a Home Page Template</li>
<li>Add a content box</li>
<li>Create a WP_Query loop to show the latest 5 posts</li>
</ul>
</section>
<!-- Examples of basic html based slides -->
<section>
<h2>Adding functionality</h2>
<h4><code>functions.php</code></h4>
<p>
functions.php is a special file that acts like a plugin to add functionality to your theme. If you're using a child theme you can use it modify and add functionality to the parent theme.
</p>
<p><br />Check out the WordPress Codex <a href="http://codex.wordpress.org/Functions_File_Explained" target="_blank">Functions File Explained</a></p>
</section>
<!-- Examples of basic html based slides -->
<section>
<h2>Adding functionality</h2>
<h4><code>functions.php</code> in a child theme</h4>
<p>
<code>functions.php</code> works like <code>style.css</code> in a child theme. It adds to and modifies the parent's <code>functions.php</code>. You don't make a copy of it in your child theme folder like you do with template files, you start a new one.
</p>
<pre><code><?php
/**
* My theme functions and definitions
*/
(all your functions go here)
?>
</code></pre>
</section>
<!-- Examples of basic html based slides -->
<section>
<h2>Adding functionality</h2>
<h4><code>functions.php</code></h4>
<p>
You can tell your theme to load external files in <code>functions.php</code>. It helps you keep <code>functions.php</code> from being overloaded with too much code.
</p>
<pre>
<code>
// Load a file from the inc folder
require_once 'inc/my-file.php';
</code>
</pre>
</section>
<!-- Examples of basic html based slides -->
<section>
<h2>Adding functionality</h2>
<h4>Keeping things organized</h4>
<p>
It's important to keep theme files organized.
<ul>
<li><strong>awesome</strong> (theme folder)
<ul>
<li><strong>css</strong> (any theme css you want to keep out of style.css)</li>
<li><strong>images</strong> (all the images used in your theme)</li>
<li><strong>inc</strong> (includes, I put functionality-related stuff in here)
<ul>
<li><strong>css</strong> (css used for functionality in the <code>inc</code> folder)</li>
<li><strong>images</strong> (images used for functionality in the <code>inc</code> folder)</li>
<li><strong>js</strong> (js used for functionality in the <code>inc</code> folder)</li>
</ul>
</li>
<li><strong>js</strong> (theme javascript)</li>
</ul>
</li>
</ul>
</p>
</section>
<!-- Examples of basic html based slides -->
<section>
<h2>Adding functionality</h2>
<h4>Hooks, Action and Filters</h4>
<h4><a href="http://codex.wordpress.org/Plugin_API#Hooks.2C_Actions_and_Filters" target="_blank">codex.wordpress.org says:</a></h4>
<blockquote>
Hooks are provided by WordPress to allow your plugin to 'hook into' the rest of WordPress...There are 2 kinds of hooks:
<ul>
<li>Actions: A custom PHP function defined in your plugin (or theme) and hooked, i.e. set to respond, to specific events that take place in WordPress. </li>
<li>Filters: Functions that WordPress passes data through, at certain points in execution, just before taking some action with the data </li>
</ul>
</blockquote>
</section>
<!-- Examples of basic html based slides -->
<section>
<h2>Adding functionality</h2>
<h4>Hooks, Action and Filters</h4>
<p>
Hooks, Actions and Filters allow you to change core WordPress functionality without breaking it.
</p>
</section>
<!-- Examples of basic html based slides -->
<section>
<h2>Adding functionality</h2>
<h4>Hooks, Action and Filters</h4>
<p>
<strong>Hooks</strong> - Points at which WordPress allows you to tap into a function and safely modify it.
</p>
<p>
Some examples are:
</p>
<ul>
<li>Changing the length of the excerpt</li>
<li>Adding Widgetized areas</li>
<li>Adding Menu areas</li>
<li>And hundreds of other things</li>
</ul>
</section>
<!-- Examples of basic html based slides -->
<section>
<h2>Adding functionality</h2>
<h4>Hooks, Action and Filters</h4>
<p>
<strong>Actions</strong> - A hook that makes something new happen when a WordPress function is triggered.
</p>
</section>
<!-- Examples of basic html based slides -->
<section>
<h2>Adding functionality</h2>
<h4>Hooks, Action and Filters</h4>
<p>
<strong>Filters</strong> - A hook that modifies a WordPress function when it is triggered.
</p>
</section>
<!-- Examples of basic html based slides -->
<section>
<h2>Adding functionality</h2>
<h4>Hooks, Action and Filters</h4>
<h4><a href="http://wordpress.tv/2013/07/31/tracy-levesque-what-you-dont-know-you-can-do-wordpress-development-for-absolutely-everyone/" target="_blank">Visual Demo of Hooks, Actions and Filters</a></h4>
<p>
From my talk at WordCamp San Francisco.<br />
19 minutes in.
</p>
</section>
<!-- Examples of basic html based slides -->
<section>
<h2>Adding functionality</h2>
<h4>Handy WordPress Functions</h4>
<p>
The following is an overview of some handy WordPress functions you can hook into to enrich your themes.
</p>
<p><br />Check out the WordPress Codex <a href="http://codex.wordpress.org/Function_Reference/" target="_blank">Entire Function Reference</a></p>
</section>
<!-- Examples of basic html based slides -->
<section>
<h2>Adding functionality</h2>
<h4>add_image_size</h4>
<p>
You can add custom images sizes (in addition to the default thumb, medium, large and original).
</p>
<pre>
<code>
add_image_size( 'my-img', 400, 400 ); // soft proportional crop mode
add_image_size( 'other-img', 200, 269, true ); // hard crop mode
</code>
</pre>
<p><br />Check out the WordPress Codex <a href="http://codex.wordpress.org/Function_Reference/add_image_size" target="_blank">add image size</a></p>
</section>
<!-- Examples of basic html based slides -->
<section>
<h2>Adding functionality</h2>
<h4>get_the_post_thumbnail</h4>
<p>
In your template you can use a tag to load your custom version of featured images.
</p>
<pre>
<code>
<?php echo get_the_post_thumbnail($page->ID, 'my-img'); ?>
</code>
</pre>
</section>
<!-- Examples of basic html based slides -->
<section>
<h2>Adding functionality</h2>
<h4>get_the_post_thumbnail</h4>
<p>
<strong>Tip!</strong> Adding custom thumbnail sizes to functions.php will not affect images previously uploaded, only images uploaded from that point on. You will need to regenerate older images.
</p>
<p>
You can use the handy <a href="http://wordpress.org/plugins/regenerate-thumbnails/" target="_blank"><strong>Regenerate Thumbnails</strong></a> plugin to create the custom sizes of your previously uploaded images.
</p>
</section>
<!-- Examples of basic html based slides -->
<section>
<h2>Adding functionality</h2>
<h4>wp_enqueue_style / wp_enqueue_script</h4>
<p>
You may want to add css and js files to your theme, for instance jQuery, or a framework like Bootstrap. A common beginner mistake is to hard code these into <code>header.php</code>. The correct way to add files to <code><head></code> is to enqueue it in your <code>functions.php</code> file.
</p>
<p><br />Check out the WordPress Codex <a href="http://codex.wordpress.org/Function_Reference/wp_enqueue_style" target="_blank">wp enqueue style</a> and
<a href="http://codex.wordpress.org/Function_Reference/wp_enqueue_script" target="_blank">wp enqueue script</a></p>
</section>
<!-- Examples of basic html based slides -->
<section>
<h2>Adding functionality</h2>
<h4>wp_enqueue_style / wp_enqueue_script</h4>
<p>Load WordPress' core copy of jQuery. If you're using jQuery with your theme you should always use WP's copy vs. an external version. </p>
<pre>
<code>
function my_scripts() {
wp_enqueue_script( 'jquery');
}
add_action( 'wp_enqueue_scripts', 'my_scripts' );
</code>
</pre>
</section>
<!-- Examples of basic html based slides -->
<section>
<h2>Adding functionality</h2>
<h4>wp_enqueue_style / wp_enqueue_script</h4>
<p>Load a script that depends on jQuery. Bootstrap is a framework that needs jQuery to run. The code below will load both jQuery and Bootstrap JS.</p>
<pre>
<code>
function add_bootstrap() {
wp_enqueue_script(
'add-bootstrap-script',
get_stylesheet_directory_uri() . '/inc/bootstrap/js/bootstrap.min.js',
array( 'jquery' )
);
}
add_action( 'wp_enqueue_scripts', 'add_bootstrap' );
</code>
</pre>
</section>
<!-- Examples of basic html based slides -->
<section>
<h2>Adding functionality</h2>
<h4>wp_enqueue_style / wp_enqueue_script</h4>
<p>Load a stylesheet and a script.</p>
<pre>
<code>function add_bootstrap() {
wp_enqueue_script(
'add-bootstrap-script',
get_stylesheet_directory_uri() . '/inc/bootstrap/js/bootstrap.min.js',
array( 'jquery' )
);
wp_enqueue_style(
'add-bootstrap-style',
get_template_directory_uri() . '/inc/bootstrap/css/bootstrap.min.css',
array(), 'all' );
}
add_action( 'wp_enqueue_scripts', 'add_bootstrap' );
</code>
</pre>
</section>
<!-- Examples of basic html based slides -->
<section>
<h2>Adding functionality</h2>
<h4>register_nav_menus</h4>
<p>
<img src="images/menus.png" class="right" />
If you have used custom menus in WordPress sites before (Appearance > Menus in the admin) you know a theme can have specific menu locations.
</p>
<p><br />Check out the WordPress Codex <a href="http://codex.wordpress.org/Function_Reference/register_nav_menus" target="_blank">register nav menus</a></p>
</section>
<!-- Examples of basic html based slides -->
<section>
<h2>Adding functionality</h2>
<h4>register_nav_menus</h4>
<p>
Use <code>register_nav_menus</code> to register your menus.
</p>
<pre>
<code>
register_nav_menus( array(
'footer-nav' => 'Footer Menu',
) );
</code>
</pre>
</section>
<!-- Examples of basic html based slides -->
<section>
<h2>Adding functionality</h2>
<h4>wp_nav_menu</h4>
<p>
Use the <code>wp_nav_menu</code> tag to assign a menu to a location in your theme.
</p>
<pre>
<code>
<?php wp_nav_menu( array( 'theme_location' => 'footer-nav' ) ); ?>
</code>
</pre>
<p><br />Check out the WordPress Codex <a href="http://codex.wordpress.org/Function_Reference/wp_nav_menu" target="_blank">wp nav menu</a></p>
</section>
<!-- Examples of basic html based slides -->
<section>
<h2>Adding functionality</h2>
<h4>wp_nav_menu</h4>
<p>
You can also use <code>wp_nav_menu</code> to load any custom menu you've created in Appearance > Menus. You can use the menu's ID, slug, or name.
</p>
<pre>
<code>
<?php wp_nav_menu( array('menu' => '2' )); ?>
</code>
</pre>
</section>
<!-- Examples of basic html based slides -->
<section>
<h2>Adding functionality</h2>
<h4>register_sidebar</h4>
<p>
<img src="images/widgets.png" class="right" />
Most themes come with specific widgetized areas -- locations in the sidebar, footer, header, etc. that you can drag and drop widgets into. You can use <code>register_sidebar</code> to create widgetized areas in your theme.
</p>
<p><br />Check out the WordPress Codex <a href="http://codex.wordpress.org/Function_Reference/register_sidebar" target="_blank">register sidebar</a></p>
</section>
<!-- Examples of basic html based slides -->
<section>
<h2>Adding functionality</h2>
<h4>register_sidebar</h4>
<p>
Use <code>register_sidebar</code> to register your widgetized areas.
</p>
<pre>
<code>
register_sidebar(array(
'name' => __( 'Header Widget Area' ),
'id' => 'headerwidget',
'description' => __( 'The header widget area.' ),
'before_widget' => '<div id="%1$s" class="headerwidget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h4 class="headerwidgettitle">',
'after_title' => '</h4>',
));
</code>
</pre>
</section>
<!-- Examples of basic html based slides -->
<section>
<h2>Adding functionality</h2>
<h4>dynamic_sidebar</h4>
<p>
Use the <code>dynamic_sidebar</code> tag to assign a widgetized area to a location in your theme.
</p>
<pre>
<code>
<?php dynamic_sidebar( 'headerwidget' ); ?>
</code>
</pre>
<p><br />Check out the WordPress Codex <a href="http://codex.wordpress.org/Function_Reference/dynamic_sidebar" target="_blank">dynamic sidebar</a></p>
</section>
<!-- Examples of basic html based slides -->
<section>
<h2>Adding functionality</h2>
<h4>dynamic_sidebar with conditional tags</h4>
<p>
Use the <code>dynamic_sidebar</code> tag along with conditional tags to load certain widget areas on certain pages.
</p>
<pre>
<code>
if(is_page( 'about' )){
dynamic_sidebar( 'aboutsidebar' );
}
if(is_page( 'contact' )){
dynamic_sidebar( 'contactsidebar' );
}
</code>
</pre>
<p>View <a href="https://github.com/TheTracyL/GDI-Code-Samples/blob/master/sidebar.php" target="_blank">the code to make this work for Twentythirteen</a></p>
</section>
<!-- Examples of basic html based slides -->
<section>
<h2>Exercise time!</h2>
<h3>Add some functionality to your theme!</h3>
<p>
Try to use any of the functions we learned today.
<ul>
<li>add_image_size</li>
<li>get_the_post_thumbnail</li>
<li>wp_enqueue_style</li>
<li>wp_enqueue_script</li>
</ul>
<ul>
<li>register_nav_menus</li>
<li>wp_nav_menu</li>
<li>register_sidebar</li>
<li>dynamic_sidebar</li>
</ul>
</p>
<p><br />Try to do it yourself (if you're stuck <a href="https://github.com/TheTracyL/GDI-Code-Samples/blob/master/functions.php" target="_blank">download functions.php off Github</a>).</p>
</section>
<!-- Examples of basic html based slides -->
<section>
<h2>Adding functionality</h2>
<h4>WP_Widget</h4>
<p>
Not only can you create widgetized areas, you can create widgets to drag and drop into those areas.
</p>
<p><br />Check out the WordPress Codex <a href="http://codex.wordpress.org/Widgets_API" target="_blank">Widgets API</a></p>
</section>
<!-- Examples of basic html based slides -->
<section>
<h2>Creating Widgets</h2>
<h4>WP_Widget</h4>
<p>
Note: You should put the widget code in its own file. If your widget is breaking the site you can easily turn it "on" and "off" while you troubleshoot code. Add a line of code to <code>functions.php</code> to load the file.
</p>
<p>"On"</p>
<pre>
<code>/* load my widget */
require_once 'inc/my-widget.php';
</code>
</pre>
"Off"
<pre>
<code>/* load my widget */
//require_once 'inc/my-widget.php';</code>
</pre>
</section>
<!-- Examples of basic html based slides -->
<section>
<h2>Creating Widgets</h2>
<h4>Example Widget: My Awesome Widget</h4>
<p>
We'll go through all the code for My Awesome Widget
</p>
<p><br /><a href="https://github.com/TheTracyL/GDI-Widget-Example/blob/master/my-widget.php" target="_blank">View the code on Github</a></p>
</section>
<!-- Examples of basic html based slides -->
<section>
<h2>Exercise time!</h2>
<h3>Make a widget</h3>
<p>
We'll be here to help.
</p>
<p><br /><a href="https://github.com/TheTracyL/GDI-Widget-Example/blob/master/my-widget.php" target="_blank">View the code on Github</a></p>
</section>
<!-- Examples of basic html based slides -->
<section>
<h2>Custom Post Types</h2>
<h3>Official description from WordPress.org</h3>
<blockquote>
A Custom Type is a Post Type you define.
</blockquote>
<p><br />Check out the WordPress Codex <a href="http://codex.wordpress.org/Post_Types" target="_blank">Post Types</a></p>
</section>
<!-- Examples of basic html based slides -->
<section>
<h2>Custom Post Types</h2>
<h4>WordPress comes with 2 major Post Types:</h4>
<p>
<img src="images/pages-posts.png" />
</p>
<p>
<strong>They both</strong>
<ul>
<li>Are unique content types with their own sets of fields</li>
<li>Have their own admin area on the WordPress admin</li>
<li>Let you add content in a repeating and consistent manner</li>
<li>Have a consistent layout on the front-end</li>
</ul>
</p>
</section>
<!-- Examples of basic html based slides -->
<section>
<h2>Custom Post Types</h2>
<h4>Create your own Post Types!</h4>
<p>
You can create your own post type that has its own fields, admin in the back-end and layout on the front-end. This is perfect for any type of repeating content you want to manage easily from the WordPress admin.
</p>
<p>
<img src="images/staff.png" />
<img src="images/recipes.png" />
<img src="images/products.png" />
<img src="images/jobs.png" />
</p>
</section>
<!-- Examples of basic html based slides -->
<section>
<h2>Custom Post Types</h2>
<h4>Custom Taxonomies</h4>
<p>
Custom Post Types can also have their own <strong>custom taxonomies</strong>. That just means they can have their own ways to group posts together.
</p>
<p>
<strong>Categories</strong> and <strong>Tags</strong> are taxonomies for Posts and Pages.
</p>
<p>
<img src="images/cat-tag.png" />
</p>
</section>
<!-- Examples of basic html based slides -->
<section>
<h2>Custom Post Types</h2>
<h4>Custom Taxonomies</h4>
<p>
If we made a custom post type "Movies."
</p>
<p>
<img src="images/movies.png" />
</p>
<p>
We could make custom taxonomies this post type
</p>
<p>
<img src="images/custom-tax.png" />
</p>
</section>
<!-- Examples of basic html based slides -->
<section>
<h2>Custom Post Types</h2>
<h4>Custom Taxonomies</h4>
<p>
<img src="images/custom-tax.png" />
</p>
<p>
Using <a href="http://codex.wordpress.org/Template_Hierarchy#The_General_Idea" target="_blank">The WordPress Template Hierarchy</a> we can make templates for the archive pages for these taxonomies.
</p>
</section>
<!-- Examples of basic html based slides -->
<section>
<h2>Custom Post Types</h2>
<p>
Front end and admin tour of the custom post type "Kittens."
</p>
<p><br />
You can also watch a video of my presentation: <a href="http://wordpress.tv/2013/04/12/tracy-levesque-custom-post-types-for-right-brained-folks/" target="_blank">Custom Post Types for Right-Brained folks on WordPress.tv</a>
</p>
</section>
<section>
<h2>Creating Custom Post Types</h2>
<p>
Note: Just like with widgets, CPT code should be put in its own file. You can put a line of code in <code>functions.php</code> to load the file.
</p>
<pre>
<code>
require_once 'inc/kittens.php';
</code>
</pre>
</section>
<!-- Examples of basic html based slides -->
<section>
<h2>Creating Custom Post Types</h2>
<h4>Step One <code>inc/kittens.php</code></h4>
<p>
<code>inc/kittens.php</code> is the file that defines all the details for our Custom Post Type and Custom Taxonomies.
</p>
<p><br />Check out the WordPress Codex <a href="http://codex.wordpress.org/Function_Reference/register_post_type" target="_blank">register post type</a></p>
</section>
<!-- Examples of basic html based slides -->
<section>
<h2>Creating Custom Post Types</h2>
<h4>Step One <code>inc/kittens.php</code></h4>
<p>
Register your custom post type and custom taxonomies. We'll go through all the code for our Kittens CPT