Slide 1

Slide 1 text

So, you want to build a WordPress theme?

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

What We’ll Cover at a high level... Theme Files The Loop Custom Queries Where to Find Help

Slide 4

Slide 4 text

Theme Files

Slide 5

Slide 5 text

Get the Template Map at http://bit.ly/WP-Map Doesn’t have to be complicated!

Slide 6

Slide 6 text

Minimum Files index.php & style.css

Slide 7

Slide 7 text

index.php

Slide 8

Slide 8 text

/* Theme Name: WordCamp Minneapolis 2013 Theme URI: http://exmaple.com Author: John & Thomas Author URI: http://example.com Description: Our first theme for WordCamp MPLS 2014 Version: 1.0 License: GNU General Public License v2 or later License URI: http://www.gnu.org/licenses/ gpl-2.0.html */ style.css

Slide 9

Slide 9 text

Optional Files • page.php • 404.php • archive.php • search.php • single.php • header.php • footer.php • sidebar.php • 404.php • functions.php

Slide 10

Slide 10 text

functions.php • Brains of Your Theme • Add Features & Functionality • Enqueue Styles & Scripts • Set Thumbnail Sizes • Custom Post Types & Taxonomies • Setup Menus • Setup Sidebars • Custom PHP

Slide 11

Slide 11 text

The Loop

Slide 12

Slide 12 text

The Loop • the_title • the_content • the_post_thumbnail • the_date • the_author Displays post information that is stored in the database.

Slide 13

Slide 13 text

The Loop Example

by on

Slide 14

Slide 14 text

Custom Queries

Slide 15

Slide 15 text

Basic Query 'post' ); $the_query = new WP_Query( $args ); if ( $the_query->have_posts() ) { while ( $the_query->have_posts() ) { $the_query->the_post(); echo '
  • ' . get_the_title() . '
  • '; } } wp_reset_postdata(); ?>

    Slide 16

    Slide 16 text

    Query + Author 'post', 'author' => 123 ); $the_query = new WP_Query( $args ); ! if ( $the_query->have_posts() ) {...} wp_reset_postdata(); ?>

    Slide 17

    Slide 17 text

    Query + Category 'post', 'author' => 123, 'cat' => 4 ); $the_query = new WP_Query( $args ); ! if ( $the_query->have_posts() ) {...} wp_reset_postdata(); ?>

    Slide 18

    Slide 18 text

    Query + Limit 'post', 'author' => 123, 'cat' => 4, 'posts_per_page' => 12 ); $the_query = new WP_Query( $args ); if ( $the_query->have_posts() ) {...} wp_reset_postdata(); ?>

    Slide 19

    Slide 19 text

    Custom Query Options • The Codex has many more options. • https://codex.wordpress.org/Class_Reference/ WP_Query

    Slide 20

    Slide 20 text

    Help!

    Slide 21

    Slide 21 text

    The Codex • Official WordPress Documentation • Example Code • Optional and Require Attributes • https://codex.wordpress.org/

    Slide 22

    Slide 22 text

    WordPress Stack Exchange • Good Support Forum • Quality Answers • Focused on Development • http://wordpress.stackexchange.com/

    Slide 23

    Slide 23 text

    Google • Google, as always, is a great resource. • Lots of blog posts and tutorials. • http://www.google.com

    Slide 24

    Slide 24 text

    What We Covered Theme Files The Loop Custom Queries Where to Find Help What it takes. How to pull in post data. How to customize the data pulled. To the rescue!

    Slide 25

    Slide 25 text

    Questions? John Heimkes IV @johnheimkes Thomas McMahon @TwisterMc via tekartist.org