Intro To WordPress – – Anatomy of a Theme



Intro To WordPress – – Anatomy of a Theme

0 0


slides-intro-to-wordpress

Intro to WordPress with DFM

On Github jaredcobb / slides-intro-to-wordpress

Intro To WordPress

Jared Cobb / @jaredcobb / alleyinteractive.com

  • We build big websites for leaders in media,entertainment, and higher education
  • WordPress.com VIP partner
  • We're currently working with Digital First Media in the move to WordPress!

We'll Talk About

  • The WordPress Admin
  • WordPress Core
  • Anatomy of a Theme
  • Customizing the Loop
  • Functions
  • Q&A

The WordPress Admin

Let's Go

WordPress Core

Files are organized:

  • Core Libraries
  • WordPress Admin
  • WordPress Content (Themes, Plugins, Media Uploads)

Anatomy of a Theme

https://developer.wordpress.org/themes/basics/template-files/#common-wordpress-template-files

The Loop

The basic format for The Loop is...

<?php
    if (have_posts()) : while (have_posts()) : the_post();

      // render the content from the database

    endwhile; else:

    endif;
  ?>

The Loop

While inside The Loop...

<?php
    if (have_posts()) : while (have_posts()) : the_post();

      <article id="post-<?php the_ID(); ?>">

        <?php the_title(); ?>

        <?php the_content(); ?>

        <a href="<?php the_permalink(); ?>">Read More</a>

      </article>

    endwhile; else:

    endif;
  ?>

Sidebars

Outside of The Loop

<?php
    if (have_posts()) : while (have_posts()) : the_post();

      // render the content from the database

    endwhile; else:

    endif;

    <?php get_sidebar(); ?>

  ?>

Customizing The Loop

How does the "normal" Loop work?

  • WordPress evaluates the URL
  • WordPress queries the database for the post(s)
  • WordPress exposes global functions that operate on a global $wp_query object

Customizing The Loop

How does a "custom" Loop work?

  • WordPress evaluates the URL
  • We build a custom query and hand it to WordPress
  • WordPress queries the database for the post(s)
  • WordPress exposes global functions that operate on a global $wp_query object

Customizing The Loop

We'll use the publicly available WP_Query() object

https://codex.wordpress.org/Class_Reference/WP_Query

Functions

AKA The Plugin API

  • Themes can have a functions.php file
  • In this file we use Hooks & Filters
  • Hooks & Filters are triggered throughout the page load lifecyle
  • You can also create your own Hooks and Filters
  • https://codex.wordpress.org/Plugin_API

The End

It's easy to get started

It takes a while to master

It's a lot of fun!