Return to Video

videos.videopress.com/.../wcnyc-levesque_dvd.mp4

  • 0:19 - 0:21
    How's everybody doin'?
  • 0:21 - 0:22
    Is everybody having a fun WordCamp?
  • 0:22 - 0:23
    Audience: Yes!
  • 0:23 - 0:25
    Tracy: Awesome
  • 0:28 - 0:31
    My name is Tracy Levesque
  • 0:31 - 0:34
    I co-own a web design and development company in Philadelphia
  • 0:34 - 0:35
    called YIKES, Inc.
  • 0:35 - 0:38
    And what I like to do is build themes.
  • 0:38 - 0:41
    I build themes for WordPress every day.
  • 0:45 - 0:48
    I do a lot of talking in front of people about WordPress
  • 0:48 - 0:53
    and one thing I talk a lot about, historically, are Child Themes
  • 0:53 - 0:56
    I've done a lot of talking about Child Themes
  • 0:59 - 1:04
    Here, it looks like I'm closing my eyes while singing a song about Child Themes
  • 1:07 - 1:11
    Here I look like a Laptronica DJ
  • 1:11 - 1:14
    Spinning about Child Themes
  • 1:14 - 1:16
    Here I am at WordCamp New York!
  • 1:16 - 1:17
    The last time there was a WordCamp New York
  • 1:17 - 1:19
    I talked about Child Themes
  • 1:19 - 1:23
    while this dude did the crossword puzzle in the corner
  • 1:24 - 1:26
    I don't really know French at all
  • 1:26 - 1:28
    Even though I have a French last name
  • 1:28 - 1:30
    This was Google Translate
  • 1:32 - 1:37
    I am an instructor for Girl Develop It Philly
  • 1:37 - 1:41
    I do all the WordPress classes and here I have a theme class.
  • 1:41 - 1:45
    And the first thing I talk about is Child Themes
  • 1:46 - 1:48
    Two months ago, people!
  • 1:48 - 1:52
    I was talking about Child Themes at the WordPress 'burbs Meetup
  • 1:52 - 1:57
    Because I also co-lead the make.wordpress.org/training Team
  • 1:57 - 2:01
    And the module I was testing at the time was on Child Themes
  • 2:04 - 2:09
    This talk is not about Child Themes
  • 2:14 - 2:16
    In the evolution of a WordPress themer
  • 2:16 - 2:21
    I often say that the journey begins here
  • 2:21 - 2:24
    When you're beginning to learn how WordPress works
  • 2:24 - 2:26
    and you start to work on themes
  • 2:26 - 2:28
    And you want to make WordPress sites
  • 2:28 - 2:31
    that look the way you want them to look
  • 2:31 - 2:34
    The place you start is you go in the Free Themes Directory
  • 2:34 - 2:37
    You look around. You have a design in mind
  • 2:37 - 2:42
    and you look and you see, "oh, this one is kinda similar to the website I want to make."
  • 2:42 - 2:45
    You take it, you make a Child Theme of it
  • 2:45 - 2:49
    and then you have your site.
  • 2:51 - 2:54
    So you may start with the default theme that comes with WordPress
  • 2:54 - 2:56
    Like Twenty Founteen shown here
  • 2:56 - 3:00
    and turn it into something that looks like
  • 3:00 - 3:01
    this.
  • 3:01 - 3:03
    The WordCamp Philly site is really just
  • 3:03 - 3:06
    a customized version of Twenty Fourteen
  • 3:09 - 3:12
    Well, folks, it's time to up your game
  • 3:12 - 3:16
    It's time to stop taking other people's themes and using plugins
  • 3:16 - 3:21
    and start designing your own themes and writing your own functionality
  • 3:21 - 3:25
    to make your themes to look the way you want
  • 3:25 - 3:26
    If you want to do this for your job
  • 3:26 - 3:30
    If you want your job to be making WordPress themes for other people
  • 3:30 - 3:35
    You have to level up and gain some theming skills
  • 3:35 - 3:38
    And I am going to tell you 6 things you can do today
  • 3:38 - 3:40
    That you can learn and aren't difficult
  • 3:40 - 3:44
    That can really improve your theme-building skills
  • 3:48 - 3:53
    Number One: Use a Starter Theme
  • 3:54 - 3:57
    Why use a Starter Theme?
  • 3:57 - 3:59
    Starter Themes are meant to be modified.
  • 3:59 - 4:01
    The people who create Starter Themes
  • 4:01 - 4:06
    Create these themes that have all the basic WordPress functionality built in
  • 4:06 - 4:07
    But not a lot of design
  • 4:07 - 4:10
    So then you as a designer can take this theme
  • 4:10 - 4:13
    and modify it and make it your very own
  • 4:13 - 4:15
    You don't have to make a Child Theme
  • 4:15 - 4:17
    They're not meant to make Child Themes of
  • 4:17 - 4:19
    You just go, you take the theme
  • 4:19 - 4:20
    You hack it up. You modify it.
  • 4:20 - 4:24
    You turn it into something that gives you a big head start
  • 4:24 - 4:26
    when you start a new project
  • 4:26 - 4:28
    Maybe you work in your favorite framework
  • 4:28 - 4:31
    You have your templates kinda of basically
  • 4:31 - 4:33
    laid out the way you want
  • 4:33 - 4:37
    and then BOOM, you install and start on the ground running
  • 4:37 - 4:42
    Some starter themes already come with your favorite frameworks built in
  • 4:42 - 4:45
    Like if you're a fan of HTML5 Boilerplate
  • 4:45 - 4:47
    Or Bootstrap
  • 4:47 - 4:48
    There are some Starter Themes that already come
  • 4:48 - 4:51
    with those things
  • 4:51 - 4:54
    And they have very little design, some have almost no design
  • 4:54 - 4:56
    So you can completely make it your own.
  • 4:58 - 5:01
    My favorite Starter Theme is Underscores
  • 5:01 - 5:04
    So let's take a look at Underscores
  • 5:07 - 5:09
    If you go to underscores.me
  • 5:09 - 5:13
    You can type in a name for your theme
  • 5:16 - 5:18
    Hit the button
  • 5:19 - 5:22
    And now you have your theme all ready to go
  • 5:24 - 5:29
    Here I have a little local install of a basic WordPress site
  • 5:29 - 5:31
    with some dummy content in it.
  • 5:31 - 5:34
    It's just using Twenty Founteen
  • 5:34 - 5:38
    Let's install that Underscores that Tracy loves so much
  • 5:38 - 5:40
    And let's see what this looks like
  • 5:51 - 5:55
    Alright, now I have the theme active
  • 5:55 - 5:57
    We'll see what it looks like
  • 5:58 - 6:01
    Oh, that doesn't very nice at all, does it?
  • 6:01 - 6:06
    You're like, "Oh my gosh, now I have this really super plain website."
  • 6:06 - 6:07
    But that's ok.
  • 6:07 - 6:09
    Because you want to make this your job, right?
  • 6:09 - 6:10
    You want to do this for a living
  • 6:10 - 6:13
    You want to put the time into taking this
  • 6:13 - 6:16
    and turning it into your own starter theme
  • 6:16 - 6:21
    that has the basic layout that you want
  • 6:21 - 6:24
    So that's what we have done at YIKES
  • 6:24 - 6:28
    We have worked on a starter theme that is based on Underscores
  • 6:28 - 6:30
    I happen to be a Bootstap fan
  • 6:30 - 6:35
    Although all my sites do not look like Bootstrap sites
  • 6:35 - 6:40
    I also use, Iike the responsive grid of Bootstrap
  • 6:40 - 6:45
    And we also have done some other custom things to Underscores.
  • 6:45 - 6:47
    I'll show you what that looks like
  • 6:55 - 6:56
    And now we have this
  • 6:56 - 6:58
    Super basic
  • 6:58 - 7:01
    It uses a Bootstrap navwalker
  • 7:01 - 7:04
    to have the Bootstrap basic nav bars
  • 7:08 - 7:11
    It's responsive
  • 7:12 - 7:14
    And it's my starting place
  • 7:14 - 7:17
    Whenever I start a new project I install this
  • 7:17 - 7:20
    and then I modify it to suit my needs.
  • 7:23 - 7:24
    And it took a lot of work
  • 7:24 - 7:28
    because Underscores is very plain
  • 7:28 - 7:30
    It doesn't have a lot going on.
  • 7:30 - 7:33
    So I invested the time and I took the work
  • 7:33 - 7:35
    to make it exactly the way I wanted it
  • 7:35 - 7:38
    because that's my job.
  • 7:38 - 7:41
    And if you want to do this for your job
  • 7:41 - 7:43
    you should take that time as well
  • 7:48 - 7:50
    Here are some other popular starter themes
  • 7:50 - 7:53
    Bones is probably the second most popular
  • 7:53 - 7:57
    basic starter theme for WordPress
  • 7:57 - 8:00
    Bootstrap has Bootstrap built into it
  • 8:00 - 8:02
    I know some people like a little bit more
  • 8:02 - 8:04
    than absolutely nothing like Quark
  • 8:04 - 8:05
    It has a little bit more to it
  • 8:05 - 8:08
    More styled menus, some columns
  • 8:08 - 8:11
    So you are not completely starting from nothing
  • 8:15 - 8:20
    Number 2 - Know the WordPress Template Hierarchy
  • 8:21 - 8:25
    Alright how many people have seen this chart?
  • 8:27 - 8:29
    Whenever this chart makes an appearance at a WordCamp
  • 8:29 - 8:33
    Some people are like "woah, what is that?"
  • 8:38 - 8:40
    And it looks really confusing - there's a lot going on
  • 8:40 - 8:42
    But it's really not so bad
  • 8:42 - 8:43
    So we're just going to take a look
  • 8:43 - 8:45
    and break down one branch
  • 8:45 - 8:46
    of the WordPress Template Hierarchy
  • 8:49 - 8:53
    And why should you know the WordPress Template Hierarchy
  • 8:54 - 8:57
    There is a lot of power in understanding that chart
  • 8:57 - 8:58
    because what that chart does
  • 8:58 - 9:01
    is it allows you to make a template
  • 9:01 - 9:04
    that will apply to a certain kind of page
  • 9:05 - 9:08
    All you have to do is name the file a certain way
  • 9:08 - 9:11
    and it will automatically apply to a certain kind of page
  • 9:11 - 9:16
    And you can use this to create all kinds of lists
  • 9:17 - 9:20
    It works really well to use posts
  • 9:20 - 9:23
    for purposes other than just posts
  • 9:29 - 9:32
    Let's take a look at category archives
  • 9:33 - 9:36
    An archive page is any kind of page
  • 9:36 - 9:38
    that groups post into:
  • 9:38 - 9:43
    tags, categories, author or date
  • 9:43 - 9:46
    If you're looking at a blog post
  • 9:46 - 9:48
    and you see the tags that are listed
  • 9:48 - 9:49
    or the categories that are listed
  • 9:49 - 9:50
    underneath of it
  • 9:50 - 9:52
    and you click on of those
  • 9:52 - 9:56
    You then go to the archive page for that term
  • 9:58 - 10:01
    In terms of category archives
  • 10:02 - 10:06
    you can make a template specifically for one category term
  • 10:06 - 10:08
    or the slug of the category
  • 10:09 - 10:12
    All categories or all archive pages
  • 10:12 - 10:16
    meaning tags, categories, author and date
  • 10:16 - 10:18
    And at the end of the road
  • 10:18 - 10:20
    if you don't have a template file
  • 10:20 - 10:22
    named a certain way that matches
  • 10:22 - 10:24
    one of these criteria it'll go to index.php
  • 10:24 - 10:29
    index.php will be the file that renders that page
  • 10:32 - 10:36
    Here, for example, if you had the category of "kittens"
  • 10:36 - 10:37
    If you had a whole bunch of posts
  • 10:37 - 10:41
    and one of your category terms was "kittens"
  • 10:41 - 10:45
    If you made a template file called category-kittens.php
  • 10:45 - 10:47
    It would then apply to only that term
  • 10:47 - 10:51
    Only if people clicked on kittens would they see category-kittens.php
  • 10:52 - 10:54
    If you had a file called category.php
  • 10:54 - 10:57
    that template would apply to all categories
  • 10:57 - 11:01
    regardless of the terms if it didn't have
  • 11:01 - 11:02
    one that matched it exactly
  • 11:03 - 11:09
    archive.php would then apply to all archives that did not have a specific template
  • 11:09 - 11:12
    It keeps going down the line
  • 11:12 - 11:14
    and WordPress keeps looking for these templates
  • 11:14 - 11:17
    and if they don't exist then it defaults to the next one
  • 11:17 - 11:19
    And at the very end of the road
  • 11:19 - 11:21
    Is index.php
  • 11:21 - 11:24
    index.php is also known as the page
  • 11:24 - 11:27
    for your list of posts or your blog page
  • 11:32 - 11:35
    Back to my awesome demo site
  • 11:35 - 11:38
    Under posts I has assigned my blog posts
  • 11:38 - 11:39
    to this Posts page
  • 11:40 - 11:43
    And I have a few categories
  • 11:43 - 11:47
    I have bunnies - looks pretty typical, right?
  • 11:47 - 11:53
    Like a basic archive page
  • 11:53 - 11:56
    Dogs - same thing.
  • 11:56 - 11:58
    Then I have...
  • 11:58 - 12:01
    Kittens!
  • 12:01 - 12:03
    Now I think the main difference
  • 12:03 - 12:05
    between this one and the other archive pages
  • 12:05 - 12:09
    is that I'm using the excerpt instead of the content
  • 12:11 - 12:14
    And a little bit of decoration
  • 12:15 - 12:16
    How is this helpful?
  • 12:20 - 12:24
    My very first WordCamp talk I attended was about Technically Philly
  • 12:24 - 12:25
    And how they used the Template Hierarchy
  • 12:25 - 12:30
    to create big huge listings of Companies and Jobs
  • 12:30 - 12:33
    And all they did was use their tags and categories
  • 12:33 - 12:39
    on their posts to create listings of Jobs and Companies
  • 12:39 - 12:43
    You can use these template pages
  • 12:43 - 12:46
    to have a unique style for a category archive
  • 12:46 - 12:47
    and use that as a listing.
  • 12:47 - 12:48
    And they're paginated
  • 12:48 - 12:52
    You can go 10 listings at a time
  • 12:52 - 12:54
    to have a Company list
  • 12:54 - 12:56
    or a Staff list
  • 12:56 - 12:59
    You can use these templates in the Template Hierarchy
  • 12:59 - 13:05
    to do some things without having to use a plugin
  • 13:06 - 13:09
    Or some other 3rd party solution
  • 13:14 - 13:18
    Number Three: Register Nav Menus
  • 13:21 - 13:23
    Why register nav menus?
  • 13:23 - 13:25
    Well you can put your nav menus exactly
  • 13:25 - 13:27
    where you want them to be.
  • 13:28 - 13:32
    For a lot of clients they have multiple navigation
  • 13:32 - 13:35
    Maybe they'll have a top nav with some basic things
  • 13:35 - 13:36
    They'll have their main nav
  • 13:36 - 13:37
    and then they'll have some footer navs
  • 13:37 - 13:39
    And then a super boring nav at the bottom
  • 13:39 - 13:41
    with all the legalise stuff
  • 13:41 - 13:43
    If I want my client to manage those
  • 13:43 - 13:45
    navigation menus moving forward
  • 13:45 - 13:47
    I should register nav menus for them
  • 13:47 - 13:49
    So they can manage them with the
  • 13:49 - 13:52
    Custom Menu Manager in WordPress
  • 13:52 - 13:56
    It makes life easier for me and for them
  • 13:59 - 14:01
    So, often times when you...
  • 14:03 - 14:08
    There's 2 parts to the next few things I'm going to explain
  • 14:08 - 14:10
    There's registering the nav menu
  • 14:10 - 14:12
    and then there's rendering it on the front end of the site
  • 14:12 - 14:15
    'Cause if you register a nav menu and there's
  • 14:15 - 14:17
    nothing to show it on the front end of the site
  • 14:17 - 14:20
    does it really exist?
  • 14:20 - 14:22
    The first thing you do is you would
  • 14:22 - 14:24
    go into your functions.php file
  • 14:24 - 14:27
    and put in this code register nav menus
  • 14:27 - 14:32
    Here I registered a nav menu caller Footer Menu
  • 14:34 - 14:36
    I gave it the ID of footer-nav
  • 14:36 - 14:39
    and the regular name "Footer Menu"
  • 14:39 - 14:41
    That regular name is what will actually
  • 14:41 - 14:44
    show up in the Custom Menu Manager
  • 14:45 - 14:46
    And then part two
  • 14:46 - 14:50
    I load this menu in a template
  • 14:51 - 14:54
    I take this little snippet of code
  • 14:54 - 14:56
    and I put this in one of the front-end templates
  • 14:56 - 15:00
    where I want the menu to actually render
  • 15:00 - 15:05
    You can use this tag without registering a nav menu first
  • 15:05 - 15:09
    You could create a custom menu in the menu manager
  • 15:09 - 15:11
    and then bring it up using this tag
  • 15:11 - 15:14
    by calling it in your template file
  • 15:18 - 15:21
    So for my test site
  • 15:24 - 15:27
    I registered 2 nav menus
  • 15:27 - 15:31
    I have Primary Menu and Footer Menu
  • 15:32 - 15:36
    So I pre-created a menu for the Footer
  • 15:36 - 15:38
    and I am just going to assign it
  • 15:39 - 15:41
    to that nav menu area
  • 15:42 - 15:43
    Save
  • 15:47 - 15:49
    Get out of the crazy cat page
  • 15:53 - 15:56
    And now I have this menu in the footer
  • 15:56 - 16:00
    So I registered my menu so it shows up in the Menu Manager
  • 16:00 - 16:02
    And then I dropped that code into the footer
  • 16:02 - 16:04
    so it shows up in the footer
  • 16:04 - 16:08
    This make life easier, managing multiple nav menu areas
  • 16:17 - 16:21
    Number Four: Register Sidebars
  • 16:26 - 16:27
    Have you ever had a point in time
  • 16:27 - 16:30
    where you had a client or maybe you got
  • 16:30 - 16:33
    a design from a print designer
  • 16:33 - 16:36
    and they're just going crazy with the Sidebars?
  • 16:36 - 16:39
    Loading different content on different pages in Sidebars
  • 16:39 - 16:41
    And then you have to download one of those
  • 16:41 - 16:44
    Sidebar widget plugins that has all these
  • 16:44 - 16:47
    complicated configuration settings.
  • 16:47 - 16:51
    Like show it on this page, but not on that page...
  • 16:51 - 16:55
    You can skip all that by just registering sidebars
  • 17:00 - 17:02
    Just like with the nav menus
  • 17:02 - 17:04
    you first go into your functions.php file
  • 17:04 - 17:07
    and you register the sidebar area.
  • 17:07 - 17:09
    You give it a name and an ID
  • 17:09 - 17:10
    and a description
  • 17:10 - 17:13
    And then you can put some HTML around
  • 17:13 - 17:17
    wrap HTML around the elements in your sidebar
  • 17:17 - 17:22
    The name is the actual name that will show up under widgets
  • 17:22 - 17:24
    And the description also shows up under widgets
  • 17:24 - 17:27
    So you can type in real words there
  • 17:27 - 17:30
    that makes sense to humans
  • 17:32 - 17:36
    And then part 2 is you load the sidebar in a template
  • 17:36 - 17:38
    So you use the dynamic sidebar tag
  • 17:38 - 17:42
    and just put the ID of the widgitized area that you made
  • 17:42 - 17:44
    In this example I made "header widget"
  • 17:44 - 17:46
    I would take this template tag
  • 17:46 - 17:51
    and I'd put it in the header.php template file
  • 18:03 - 18:13
    So I have 5 widget areas registered for this website
  • 18:13 - 18:16
    I have 4 footer widget areas
  • 18:16 - 18:20
    I have a lot of clients that want lots of information
  • 18:20 - 18:21
    all jammed into the footer
  • 18:21 - 18:25
    So I made 4 footer widget areas.
  • 18:28 - 18:33
    I'm just gonna pop some content in them
  • 18:49 - 18:53
    Oops, I lost one. Oh, well.
  • 18:56 - 19:02
    And now it'll be super easy for my clients to manage those footer widget areas
  • 19:02 - 19:06
    All they have to do is go into Appearance > Widgets
  • 19:06 - 19:09
    and they can drag and drops stuff in there and they can move it around
  • 19:09 - 19:13
    They can change the order, they can put custom menus in there
  • 19:13 - 19:20
    Instead of hard coding things in the sidebars or having to use plugins
  • 19:21 - 19:24
    And some of those widget plugins are just Crazytown
  • 19:24 - 19:32
    There's some themes that just have a bazillion complicated widget configuraton settings
  • 19:38 - 19:42
    Number Five: Register Custom Thumbnail Sizes
  • 19:46 - 19:50
    One thing that's nice about registering custom thumbnail sizes
  • 19:50 - 19:54
    is controlling the consistency of image sizes
  • 19:55 - 19:57
    If you're using the featured images for posts
  • 19:57 - 20:04
    like perhaps in your list of posts you are showing the featured image
  • 20:04 - 20:07
    and then they can pop pretty much anything in there
  • 20:07 - 20:11
    and they can be all weird sized
  • 20:11 - 20:14
    Or if you have a nice grid layout of something
  • 20:14 - 20:16
    and you're using the featured image you want all the thumbnails
  • 20:16 - 20:18
    to be nice and consistent.
  • 20:18 - 20:21
    But you don't necessarily want to use the ones that come build into WordPress
  • 20:21 - 20:27
    WordPress allows you to have four image sizes in the Media Manager
  • 20:27 - 20:31
    You have the original, large, medium and thumbnail
  • 20:31 - 20:33
    And you can control the sizes of that,
  • 20:33 - 20:36
    but maybe you want something unique
  • 20:36 - 20:39
    And you want to keep the medium size
  • 20:39 - 20:43
    but you also want to have a unique size as well.
  • 20:46 - 20:51
    So to add a custom image size you just pop this in your functions.php
  • 20:51 - 20:55
    You add an image size, you give it an ID
  • 20:55 - 20:57
    and then you give the dimensions
  • 20:57 - 21:00
    Like you can say I want it 400 by 400
  • 21:00 - 21:02
    And there's 2 different modes of cropping
  • 21:02 - 21:05
    There's the soft proportional crop mode meaning that
  • 21:05 - 21:10
    if you have a rectangle, in the first example
  • 21:10 - 21:14
    it'll shrink the longest or widest down to 400
  • 21:14 - 21:17
    and then keep it a rectangle
  • 21:17 - 21:22
    If you put "true" in there that's the hard crop mode
  • 21:22 - 21:27
    Meaning it'll take the shortest width or height
  • 21:27 - 21:29
    shrink that down and then chop the top and bottom off
  • 21:29 - 21:32
    or chop the sides off so you have a nice perfectly filled image
  • 21:32 - 21:34
    I'm a fan of the hard crop
  • 21:34 - 21:37
    Because I want all of my images to look the same
  • 21:37 - 21:40
    I don't want some this way some that way
  • 21:40 - 21:43
    Just looks inconsistent and ugly
  • 21:43 - 21:50
    And kind of new is you can determine where you want the crop to start from
  • 21:50 - 21:52
    You can have it start from the top or the center
  • 21:52 - 21:56
    or left or right or the bottom
  • 21:56 - 21:59
    Instead of just by default it focuses in on the center
  • 21:59 - 22:01
    and crops from there
  • 22:01 - 22:06
  • 22:06 - 22:08
    Then again you have to use them in your templates
  • 22:08 - 22:12
    In a single post or page you can use the post thumbnail
  • 22:12 - 22:18
    and then you just enter in the ID of the custom thumbnail size you just used
  • 22:18 - 22:22
    And then in a Loop you can say get the post thumbnail
  • 22:22 - 22:25
    and you put in the ID
  • 22:25 - 22:30
  • 22:30 - 22:33
    So in my example I made a custom thumbnail size
  • 22:33 - 22:40
    for featured images on my Posts page
  • 22:40 - 22:45
    And they're all nice and consistent and the same size
  • 22:45 - 22:46
    Instead of having to say to the client,
  • 22:46 - 22:48
    "well you gotta like crop it first in Photoshop
  • 22:48 - 22:50
    and then upload it."
  • 22:50 - 22:53
    It does all the work for them
  • 22:53 - 23:01
  • 23:01 - 23:04
    Number Six, and this is the big one
  • 23:04 - 23:11
    Write your own queries
  • 23:11 - 23:15
    And why would you want to learn how to do something like that?
  • 23:15 - 23:19
    Use fewer plugins
  • 23:19 - 23:23
    It's handy to be able to bring up a list of posts on your pages
  • 23:23 - 23:30
    Clients often want News on their home page in a nice box
  • 23:30 - 23:32
    that maybe shows their last few posts
  • 23:32 - 23:35
    or Announcements or Events or something like that
  • 23:35 - 23:40
    Then you'd have to go and find a plugin that kinda does what you want
  • 23:40 - 23:42
    But they're never completely perfect
  • 23:42 - 23:44
    There's always something weird about it
  • 23:44 - 23:49
    And then it doesn't style right and they're a pain.
  • 23:49 - 23:51
    When you write your own queries you can bring up the exact
  • 23:51 - 23:54
    information you want and the exact fields you want
  • 23:54 - 23:57
    You can wrap the HTML you want around it
  • 23:57 - 24:01
    and style it exactly the way you want so it looks perfect
  • 24:01 - 24:05
  • 24:05 - 24:08
    So here is the code
  • 24:08 - 24:14
    First you name your query and then you have a Loop
  • 24:14 - 24:19
    The Loop is, like I like to say, making a sandwich
  • 24:19 - 24:21
    When you make a sandwich you have your bread
  • 24:21 - 24:23
    you have your ingredients and you have your other piece of bread
  • 24:23 - 24:28
    It's a set of instructions of what ingredients you want in your sandwich
  • 24:28 - 24:32
    In the case of WPQuery, or the Loop
  • 24:32 - 24:36
    You're saying I want to show the Title, I want the Content,
  • 24:36 - 24:40
    I want the Date and I'm done
  • 24:40 - 24:45
    So that's writing your own Loops, writing your own queries
  • 24:45 - 24:50
    Telling a template what to get from the database and display it
  • 24:50 - 24:55
    and how many times you want it displayed
  • 24:55 - 25:02
    Every page on WordPress has its own Loop
  • 25:02 - 25:05
    that displays that page, that post or list of posts
  • 25:05 - 25:07
    or whatever content that you're looking at
  • 25:07 - 25:09
    That's the main Loop
  • 25:09 - 25:12
    If you want to add an additional query inside the main Loop
  • 25:12 - 25:16
    you gotta tack on this wp reset post data
  • 25:16 - 25:20
    that restores the main Loop so you don't break the page
  • 25:20 - 25:25
  • 25:25 - 25:29
    And here is further detail on the kind of arguements
  • 25:29 - 25:32
    that you can put into your query
  • 25:32 - 25:35
    You can have author name
  • 25:35 - 25:41
    So in my query I say show me all posts written by Tracy
  • 25:41 - 25:44
    categorized as cooking, tagged with chocolate.
  • 25:44 - 25:50
    I want you to show 5 posts, ordered by date in descending order
  • 25:50 - 25:56
    You could have a whole week-long WPQuery camp
  • 25:56 - 25:57
    there is so much you can do with this
  • 25:57 - 26:00
    But in its most basic form you just tell it
  • 26:00 - 26:06
    exactly what you want to display and how many posts you want to display
  • 26:06 - 26:15
    And then a Pro Tip: Put your WPQuery in the Transients API
  • 26:15 - 26:17
    Every time WordPress runs a query
  • 26:17 - 26:21
    it needs to go to the database, find the data,
  • 26:21 - 26:24
    grab the data, display it on a page
  • 26:24 - 26:26
    This happens in seconds, but it takes up resources
  • 26:26 - 26:30
    it takes up computer memory
  • 26:30 - 26:33
    With the Transients API you can cache a query
  • 26:33 - 26:44
    So I can say put the results in a transient and expire after 12 hours
  • 26:44 - 26:46
    So what happens is it takes a picture of this query
  • 26:46 - 26:50
    and then just displays it without having to do all that stuff of
  • 26:50 - 26:52
    going to the database, getting the content,
  • 26:52 - 26:54
    getting it out, displaying it for you.
  • 26:54 - 26:56
    This is cached for 12 hours
  • 26:56 - 26:59
    And where you determine the amount of time
  • 26:59 - 27:05
    is over here, so I'm saying 12 times hours in seconds
  • 27:05 - 27:10
    So I can say 1 times hours in seconds, that would be 1 hour
  • 27:10 - 27:13
    Save my query for 1 hour and then go see if anything's changed
  • 27:13 - 27:14
    save it again
  • 27:14 - 27:20
    You can set it to days, however time you want
  • 27:20 - 27:21
    depending on the frequency that
  • 27:21 - 27:24
    this information it is querying is updated.
  • 27:24 - 27:32
  • 27:32 - 27:34
    So I created a simple little query
  • 27:34 - 27:38
    on the homepage template that I made
  • 27:38 - 27:42
    named page-home.php
  • 27:42 - 27:49
    I'm just saying I want the latest 4 posts that I posted
  • 27:49 - 27:55
    I'm going to put it in a box on the home page
  • 27:55 - 27:58
  • 27:58 - 28:03
    So I'm going to go to the home page and switch to that template
  • 28:03 - 28:12
  • 28:12 - 28:15
    And now here is my WPQuery
  • 28:15 - 28:18
    and it shows the last 4 posts
  • 28:18 - 28:21
    Simple, right?
  • 28:21 - 28:31
  • 28:31 - 28:35
    I know I said there 6 things, but I got 2 bonus things at the end here
  • 28:35 - 28:38
    Bonus thing number 1 to up your design game
  • 28:38 - 28:43
    is use a CSS pre-processor like Sass or LESS
  • 28:43 - 28:49
    I'd say, maybe, I dunno, a year ago.
  • 28:49 - 28:51
    I was totally that guy that said,
  • 28:51 - 28:56
    "Oh, I know I should really be using a CSS pre-processor, but..."
  • 28:56 - 28:58
    Maybe it was fear of learning curve
  • 28:58 - 29:02
    Maybe it was I didn't really totally understand how awesome it was
  • 29:02 - 29:06
    But I kind of blew it off until WordPress core started using Sass
  • 29:06 - 29:08
    And I was kind of going between
  • 29:08 - 29:09
    should I use LESS, should I use Sass
  • 29:09 - 29:12
    I don't know
  • 29:12 - 29:14
    And then when WordPress core decided to use Sass
  • 29:14 - 29:16
    I was like "well, I gotta learn it now."
  • 29:16 - 29:21
    And I think it took me a day...
  • 29:21 - 29:24
    Well, I just sat down, I did some tutorials on the web
  • 29:24 - 29:27
    It took me maybe, I don't know
  • 29:27 - 29:30
    15 minutes to get the gist of the whole thing
  • 29:30 - 29:33
    and an hour to learn the basics
  • 29:33 - 29:41
    And a day to never EVER want to do CSS the old way ever again
  • 29:41 - 29:45
    Tracy Rotton did a Sass talk earlier today
  • 29:45 - 29:47
    So I would have mentioned it, but it already happened.
  • 29:47 - 29:51
    But anyway, look it up on wordpress.tv when it comes up
  • 29:51 - 29:56
    Oh, I got the times up sign
  • 29:56 - 29:56
    Sass is great!
  • 29:56 - 29:57
    Learn it, it's not hard
  • 29:57 - 29:59
    I wrote a blog post on it
  • 29:59 - 30:01
    It's awesome, it'll change your life
  • 30:01 - 30:03
    And it's fun! It makes CSS fun again.
  • 30:03 - 30:05
    I am not lying
  • 30:05 - 30:09
    Bonus Two: Up Your Dev Game
  • 30:09 - 30:12
    Use version control like Git or Subversion
  • 30:12 - 30:14
    Now I'm a designer, right?
  • 30:14 - 30:18
    I'm not some command line expert
  • 30:18 - 30:23
    But I use Git and it's great
  • 30:23 - 30:28
    and I can't imagine ever wanting to develop ever again without it
  • 30:28 - 30:31
    and I hear so many excuses why not to use version control
  • 30:31 - 30:35
    And I think people really just haven't used it
  • 30:35 - 30:38
    And they're afraid of it, because it seems complicated
  • 30:38 - 30:41
    It's not complicated
  • 30:41 - 30:43
    I have a link to learn version control with Git
  • 30:43 - 30:45
    It has really great tutorials
  • 30:45 - 30:47
    All super designer friendly
  • 30:47 - 30:49
    You don't have to do it at the command line
  • 30:49 - 30:50
    I don't use the command line
  • 30:50 - 30:56
    I use Tortoise Git for Windows
  • 30:56 - 30:58
    and all I have to do is right-click and make commits
  • 30:58 - 30:59
    and it's great.
  • 30:59 - 31:02
    It's great when you're working with a team especially
  • 31:02 - 31:04
    You never have one of those
  • 31:04 - 31:06
    "Oh, crap" moments ever again
  • 31:06 - 31:10
    Even when you don't mean to in FTP
  • 31:10 - 31:12
    you can accidentally overwrite the home page
  • 31:12 - 31:14
    Just by accident you put it in the wrong folder
  • 31:14 - 31:15
    and you didn't mean to. And you're like,
  • 31:15 - 31:20
    "oh my god, now the page that is live right now is wrong."
  • 31:20 - 31:22
    You don't have to do that ever again
  • 31:22 - 31:23
    You don't have to worry ever again
  • 31:23 - 31:25
    about putting something in the wrong place
  • 31:25 - 31:28
    and messing up a live site
  • 31:28 - 31:35
    So I would say please start using version control
  • 31:35 - 31:38
    Oh, and PS, if you do want to learn about Child Themes
  • 31:38 - 31:43
    You can go to Gabriela Levi's presentation tomorrow at 3:15
  • 31:43 - 31:46
    The end!
  • 31:46 - 31:51
    [Applause]
  • 31:51 - 32:01
    Tracy: Questions?
  • 32:01 - 32:02
    Audience member: A couple times you mentioned
  • 32:02 - 32:06
    putting things in your theme's function file
  • 32:06 - 32:06
    Tracy: Yes
  • 32:06 - 32:09
    Audience member: I've got caught on a couple of my clients
  • 32:09 - 32:11
    when they decided to install something like
  • 32:11 - 32:15
    WPTouch or theme switcher for mobile
  • 32:15 - 32:16
    As an easy fix
  • 32:16 - 32:20
    And, of course, all my custom stuff that was in the function file
  • 32:20 - 32:24
    wasn't copied over to the mobile theme
  • 32:24 - 32:28
    Why not do a custom plugin that just goes along with your theme?
  • 32:28 - 32:30
    And keep the functions file cleaner
  • 32:30 - 32:37
    Tracy: [laughs] I got a head shake and a head nod in the row
  • 32:37 - 32:41
    So the question was.
  • 32:41 - 32:45
    You talked about putting stuff in your functions file
  • 32:45 - 32:49
    but then the client installs a plugin that makes a mobile version of the site
  • 32:49 - 32:51
    We don't really do that anymore
  • 32:51 - 32:53
    We do everything responsive
  • 32:53 - 32:56
    So for us and the work we do at YIKES
  • 32:56 - 32:58
    It's kind of a non issue
  • 32:58 - 33:03
    But I suppose that if you do foresee that
  • 33:03 - 33:06
    your client is going to use something like WPTouch
  • 33:06 - 33:09
    you could put it in a plugin
  • 33:09 - 33:10
    Audience member: Well also, if your client suspects
  • 33:10 - 33:12
    that something is wrong and can't get a hold of you,
  • 33:12 - 33:15
    they can deactivate your custom plugin
  • 33:15 - 33:19
    Where they can't deactivate your functions file of the theme
  • 33:19 - 33:25
    Tracy: That's true, but I rarely put anything too crazy in the functions file
  • 33:25 - 33:31
    Especially if we're doing stuff like registering nav menus
  • 33:31 - 33:34
    and widget areas, that's not anything too wacky
  • 33:34 - 33:36
    that's going to wreck anything
  • 33:36 - 33:38
    That's basic WordPress functionality
  • 33:38 - 33:40
    I mean that's a hard question for me
  • 33:40 - 33:42
    because I'd have look at it on a case-by-case basis
  • 33:42 - 33:47
    Like what's the client doing that's breaking the site all the time
  • 33:47 - 33:53
    You know? I don't know.
  • 33:53 - 33:57
    Anything else?
  • 33:57 - 34:00
    Tom are you raising your hand or are you saying I gotta go
  • 34:00 - 34:02
    Audience member: I have a suggestions, you could put an include
  • 34:02 - 34:03
    file in if you want to
  • 34:03 - 34:08
    Tracy: Yeah, but still it's up to us to comment it
  • 34:08 - 34:13
    out if they can't get a hold of us.
  • 34:13 - 34:17
    Bye everybody!
Title:
Video Language:
English

English subtitles

Incomplete

Revisions