SlideShare ist ein Scribd-Unternehmen logo
1 von 55
Downloaden Sie, um offline zu lesen
THINGS YOU SHOULD KNOW 
ABOUT WORDPRESS 
(but were always afraid to ask) 
Power Users Track 
WordCamp Raleigh 2014 
Saturday, November 8th, 2014 
Michael McNeill - @michaelrmcneill #wcraleigh
ABOUT ME 
• Developer and Support Engineer in ITS Web Services at the University of 
North Carolina at Chapel Hill, where I help to manage two HUGE multisite 
networks that operate a total of almost 8,500+ sites. 
• Owner and Developer at MRMcDEV, Inc. my personal consulting company. 
• Co-Curator (Executive Director) of TEDxUNC, a non-profit organization 
dedicated to bringing “Ideas Worth Spreading” to Carolina. 
• I’ve been using WordPress for over 5 years now, and I use it for almost all my 
client projects. 
• I’ve worked on exciting and wide ranging projects, such as Black Enterprise 
Magazine, Mackay Communications, WiredHoods, smallbiztechnology.com, 
ALOHA, and MAXI Promotion and Records. I’ve also contracted for DRS 
Technologies, the United States Department of the Defense, and numerous 
other companies. 
@michaelrmcneill 
#wcraleigh
A QUICK ROADMAP… 
1. The WordPress APIs - What they are, how to find them, and 
how to use them. 
2. The WordPress Template Hierarchy - What it is, which file 
generates a certain type of page, and how to use it to your 
advantage. 
3. The WordPress Database - What is stored there, why it is 
stored there, how is it stored there, and how should you 
properly use the data inside it. 
4. A few “tricks of the trade” - Version Control and Vagrant 
@michaelrmcneill 
#wcraleigh
THE WORDPRESS CODEX 
@michaelrmcneill 
#wcraleigh
BOOKMARK IT! 
http://codex.wordpress.org 
@michaelrmcneill 
#wcraleigh
WHAT IS IT? 
The WordPress Manual written for all users, Designers and 
Developers alike. 
@michaelrmcneill 
#wcraleigh
USE IT & IMPROVE IT. 
When you first have a question, go to the Codex first. 
The Codex is a living document, and anyone with a WordPress.org account can 
edit it and improve it. If you see something out of date, or flat out wrong, update it. 
@michaelrmcneill 
#wcraleigh
THE WORDPRESS APIs 
@michaelrmcneill 
#wcraleigh
WHAT’S AN API? 
• APIs are Application Programming Interfaces. 
• Think about it like this, APIs are basically a contract 
between two things stating: "If you tell me this, I 
will do this.” 
@michaelrmcneill 
#wcraleigh
WHAT DO THE WORDPRESS 
APIs DO? 
• They help you do things using tools that 
WordPress gives you. 
• That makes development EASIER!! 
@michaelrmcneill 
#wcraleigh
HOW DO I FIND THEM? 
• Identify what you are trying to do. 
• Then go to the ___________ and search for it. 
• If that doesn’t work, try using Google, just 
remember to cross-check against what the Codex 
says. 
@michaelrmcneill 
#wcraleigh
HOW DO I USE THEM? 
• The format is basically the same across all function 
reference articles. 
• There are 3 primary sections. 
1. The description of the function. 
2. The parameters the function wants/needs. 
3. What values, if any, the function returns. 
@michaelrmcneill 
#wcraleigh
WORDPRESS PAGE LIFE CYCLE 
• The WordPress page life cycle is a combination of 
the events that take place from when a browser 
requests a page to when the server returns the 
rendered page to the browser. 
• That sounds simple, but there are a lot of things 
going on that get you the end result. 
@michaelrmcneill 
#wcraleigh
@michaelrmcneill 
#wcraleigh
WORDPRESS HOOKS 
• Hooks are extremely important to WordPress 
developers. 
• They enable us to literally hook into parts of the 
WordPress page life cycle to retrieve, insert, and 
modify data, and they allow us to take certain 
actions behind the scenes, before a user sees what 
is occurring. 
@michaelrmcneill 
#wcraleigh
WORDPRESS HOOKS 
@michaelrmcneill 
#wcraleigh 
• Two Classifications 
• Actions 
• Actions are triggered by specific events that take place in WordPress, 
such as publishing a post, activating a plugin, or loading an admin 
screen. 
• For a comprehensive list of actions, check this Codex article out: 
http://codex.wordpress.org/Plugin_API/Action_Reference 
• Filters 
• Filters are functions that WordPress passes data through, that are 
primarily responsible for intercepting, managing, and returning data, 
before rendering or saving that data. 
• For a pretty comprehensive list of filters, check this Codex article 
out: http://codex.wordpress.org/Plugin_API/Filter_Reference
WORDPRESS HOOKS 
• I’m sure you have the question, when should I use which 
hook? 
• Use actions when you want to add something to the 
existing page such as stylesheets, JavaScript, or send an 
email when an event has happened. 
• Use filters when you want to manipulate data coming out 
of the database prior to going to the browser, or coming 
from the browser prior to going into the database. 
@michaelrmcneill 
#wcraleigh
THE WORDPRESS PAGE 
TEMPLATE HIERARCHY 
@michaelrmcneill 
#wcraleigh
WHAT IS THE TEMPLATE 
HIERARCHY? 
WordPress templates fit together like the pieces of a 
puzzle to generate the pages on your WordPress site. 
Some templates (the header and footer templates 
for example) are used on almost all pages, while 
others are used only under specific conditions. The 
template hierarchy decides what template file or files 
WordPress will use to display a certain type of page. 
@michaelrmcneill 
#wcraleigh
@michaelrmcneill 
#wcraleigh
LET’S LOOK AT THE BASICS 
@michaelrmcneill 
#wcraleigh
THE NEEDS OF A THEME 
• To have a functioning, bare minimum theme you 
need two things. 
• style.css - A stylesheet. 
• index.php - An index file that will render the 
output of the page. 
@michaelrmcneill 
#wcraleigh
header.php 
@michaelrmcneill 
#wcraleigh
footer.php 
@michaelrmcneill 
#wcraleigh
single.php 
@michaelrmcneill 
#wcraleigh
sidebar.php 
@michaelrmcneill 
#wcraleigh
SINGLE POST RULES 
@michaelrmcneill 
#wcraleigh 
1. single-post.php 
2. single.php 
3. index.php
PAGE TEMPLATE RULES 
1. Custom Template defined in WP Admin 
2. page-<slug>.php 
3. page-<id>.php 
4. page.php 
5. index.php 
@michaelrmcneill 
#wcraleigh
HOME PAGE TEMPLATE RULES 
• front-page.php 
• Settings > Reading 
• Static Page 
1. Follows the page template rules. 
@michaelrmcneill 
#wcraleigh 
• Blog Page 
1. home.php 
2. index.php
SINGLE CUSTOM POST RULES 
1. single-<posttype>.php 
2. single.php 
3. index.php 
@michaelrmcneill 
#wcraleigh
CUSTOM POST TYPE RULES 
1. archive-<posttype>.php 
2. archive.php 
3. index.php 
@michaelrmcneill 
#wcraleigh
CATEGORY PAGES 
1. category-<slug>.php 
2. category-<id>.php 
3. category.php 
4. archive.php 
5. index.php 
@michaelrmcneill 
#wcraleigh
TAG PAGES 
@michaelrmcneill 
#wcraleigh 
1. tag-<slug>.php 
2. tag-<id>.php 
3. tag.php 
4. archive.php 
5. index.php
AUTHOR PAGES 
1. author-<nicename>.php 
2. author-<id>.php 
3. author.php 
4. archive.php 
5. index.php 
@michaelrmcneill 
#wcraleigh
ATTACHMENT RULES 
1. MIME-type.php (e.x. text.php, video.php, 
image.php) 
2. attachment.php 
3. single_attachment.php 
4. single.php 
5. index.php 
@michaelrmcneill 
#wcraleigh
CODEX ARTICLE 
http://codex.wordpress.org/Template_Hierarchy 
INTERACTIVE WEBSITE! 
http://wphierarchy.com/ 
@michaelrmcneill 
#wcraleigh
WORDPRESS DATA 
@michaelrmcneill 
#wcraleigh
WORDPRESS DATA 
• A WordPress website consists of three main 
elements: 
• The WordPress installation itself 
• The contents of the wp-content directory which 
includes the themes, plugins and uploads 
• The database, where all the content is stored. 
@michaelrmcneill 
#wcraleigh
TYPES OF WORDPRESS 
CONTENT 
@michaelrmcneill 
#wcraleigh 
• posts 
• pages 
• custom post types 
• attachments 
• links 
• menu items
ASSOCIATED DATA 
(POSTMETA) 
• categories 
• tags 
• custom taxonomies and terms 
• post metadata 
@michaelrmcneill 
#wcraleigh
OTHER TYPES OF CONTENT 
@michaelrmcneill 
#wcraleigh 
• widgets 
• options 
• users 
• sites (for multisite)
@michaelrmcneill 
#wcraleigh
A FEW NOTES… 
• In the next few slides, I’m using the wp_ prefix by 
default. You can change this (and you might have), 
but the concepts are the same. 
• A multisite installation will have some extra tables. 
I haven't included those here as that's outside the 
scope of this presentation. 
@michaelrmcneill 
#wcraleigh
THE WORDPRESS DATABASE 
STRUCTURE 
Most of the tables in the WordPress database are 
linked to one or more other tables via a specific field. 
This field is generally a unique ID for each record 
such as a post_id. 
@michaelrmcneill 
#wcraleigh
THE WORDPRESS DATABASE 
STRUCTURE 
TABLE DATA STORED LINKED TO 
wp_posts Posts, pages, attachments, 
revisions and menu items 
@michaelrmcneill 
#wcraleigh 
wp_postmeta 
(using post_id) 
wp_term_relationships 
(using post_id) 
wp_postmeta Post metadata wp_posts 
(using post_id)
THE WORDPRESS DATABASE 
STRUCTURE 
TABLE DATA STORED LINKED TO 
wp_comments Comments 
@michaelrmcneill 
#wcraleigh 
wp_posts 
(using post_id) 
wp_commentmeta 
(using comment_id) 
wp_commentmeta Comment metadata wp_comments 
(using comment_id)
THE WORDPRESS DATABASE 
STRUCTURE 
TABLE DATA STORED LINKED TO 
wp_users Users 
@michaelrmcneill 
#wcraleigh 
wp_posts 
(using post_author) 
wp_usermeta 
(using user_id) 
wp_usermeta Metadata for each user wp_users 
(using user_id)
THE WORDPRESS DATABASE 
STRUCTURE 
TABLE DATA STORED LINKED TO 
@michaelrmcneill 
#wcraleigh 
wp_links 
(DEPRECATED!) 
Information related to 
Links 
wp_term_relationships 
(using link_id) 
wp_options 
Site settings and options 
(set via the Settings 
screens and via plugins and 
themes) as well as widgets 
None
THE WORDPRESS DATABASE 
STRUCTURE 
TABLE DATA STORED LINKED TO 
wp_term_relationships Relationships between 
posts and taxonomies 
@michaelrmcneill 
#wcraleigh 
wp_posts 
(using post_id) 
wp_term_taxonomy 
(using term_taxonomy_id) 
wp_term_taxonomy Taxonomies (including 
categories and tags) 
wp_term_relationships 
(using term_taxonomy_id) 
wp_terms 
Your categories and tags 
and the terms assigned to 
custom taxonomies 
wp_term_taxonomy 
(using term_id)
HOW TO USE THE 
WORDPRESS DB? 
WordPress defines a class called wpdb, which 
contains a set of functions used to interact with a 
database. Its purpose is to provide an easy to use 
interface with the WordPress database. 
@michaelrmcneill 
#wcraleigh
$wpdb 
Methods in the wpdb() class should not be called 
directly. You should use the global $wpdb object 
instead. 
@michaelrmcneill 
#wcraleigh
A LARGE WARNING 
Any function that executes SQL queries, can be 
vulnerable to SQL injection attacks. To prevent that, 
you should escape all SQL. Make sure to review the 
______ to double-check if the function you plan to 
use escapes SQL for you or leaves it un-escaped! 
@michaelrmcneill 
#wcraleigh
TRICKS OF THE TRADE 
@michaelrmcneill 
#wcraleigh
VAGRANT AND VVV 
http://vagrantup.com 
https://github.com/Varying-Vagrant-Vagrants/VVV 
A great tutorial: http://tangrufus.com/start-wordpress- 
development-varying-vagrant-vagrants/ 
GIT AND GITHUB 
Great intro guide and cheat sheet: http:// 
rogerdudler.github.io/git-guide/ 
GitHub: https://github.com 
Deploy (Automated Deployment): https:// 
www.deployhq.com 
@michaelrmcneill 
#wcraleigh
QUESTIONS? 
@michaelrmcneill 
#wcraleigh

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (20)

Getting started with WordPress development
Getting started with WordPress developmentGetting started with WordPress development
Getting started with WordPress development
 
WordPress plugins
WordPress pluginsWordPress plugins
WordPress plugins
 
WordPress APIs
WordPress APIsWordPress APIs
WordPress APIs
 
[GeekTalk#2] Takaaki Mizuno - Api Url Design
[GeekTalk#2] Takaaki Mizuno - Api Url Design[GeekTalk#2] Takaaki Mizuno - Api Url Design
[GeekTalk#2] Takaaki Mizuno - Api Url Design
 
Zero To WordPress Plubish
Zero To WordPress PlubishZero To WordPress Plubish
Zero To WordPress Plubish
 
CSI: WordPress -- Getting Into the Guts
CSI: WordPress -- Getting Into the GutsCSI: WordPress -- Getting Into the Guts
CSI: WordPress -- Getting Into the Guts
 
Building microservices with Node.js - part 2
Building microservices with Node.js - part 2Building microservices with Node.js - part 2
Building microservices with Node.js - part 2
 
Use WordPress to become a social proprietor
Use WordPress to become a social proprietorUse WordPress to become a social proprietor
Use WordPress to become a social proprietor
 
Angular Remote Conf - Building with Angular & WordPress
Angular Remote Conf - Building with Angular & WordPressAngular Remote Conf - Building with Angular & WordPress
Angular Remote Conf - Building with Angular & WordPress
 
From Zero To WordPress
From Zero To WordPressFrom Zero To WordPress
From Zero To WordPress
 
JSON REST API for WordPress
JSON REST API for WordPressJSON REST API for WordPress
JSON REST API for WordPress
 
Newspapers with WordPress
Newspapers with WordPressNewspapers with WordPress
Newspapers with WordPress
 
Why you should be using WordPress child themes
Why you should be using WordPress child themesWhy you should be using WordPress child themes
Why you should be using WordPress child themes
 
The Why, When, How of WordPress Child Themes
The Why, When, How of WordPress Child ThemesThe Why, When, How of WordPress Child Themes
The Why, When, How of WordPress Child Themes
 
WordCamp Minnepolis 2015: From Zero To WordPress Publish
WordCamp Minnepolis 2015: From Zero To WordPress PublishWordCamp Minnepolis 2015: From Zero To WordPress Publish
WordCamp Minnepolis 2015: From Zero To WordPress Publish
 
2010 11 pubcon_hendison_wordpress
2010 11 pubcon_hendison_wordpress2010 11 pubcon_hendison_wordpress
2010 11 pubcon_hendison_wordpress
 
2010 11 pubcon_hendison-hosting
2010 11 pubcon_hendison-hosting2010 11 pubcon_hendison-hosting
2010 11 pubcon_hendison-hosting
 
Using composer with WordPress
Using composer with WordPressUsing composer with WordPress
Using composer with WordPress
 
How to WordPress: the basics, part 1
How to WordPress:  the basics, part 1How to WordPress:  the basics, part 1
How to WordPress: the basics, part 1
 
Web development basics2
Web development basics2Web development basics2
Web development basics2
 

Andere mochten auch

The five things you should know about me
The five things you should know about meThe five things you should know about me
The five things you should know about me
KershtinViernes0422
 
Маркетинг план юст
Маркетинг план юстМаркетинг план юст
Маркетинг план юст
Елена Шальнова
 
Lifestyle unit 6
Lifestyle unit 6Lifestyle unit 6
Lifestyle unit 6
Les Davy
 
Multimedia01
Multimedia01Multimedia01
Multimedia01
Les Davy
 

Andere mochten auch (20)

The five things you should know about me
The five things you should know about meThe five things you should know about me
The five things you should know about me
 
WordPress Café: Using WordPress as a Framework
WordPress Café: Using WordPress as a FrameworkWordPress Café: Using WordPress as a Framework
WordPress Café: Using WordPress as a Framework
 
WordPress development paradigms, idiosyncrasies and other big words
WordPress development paradigms, idiosyncrasies and other big wordsWordPress development paradigms, idiosyncrasies and other big words
WordPress development paradigms, idiosyncrasies and other big words
 
10 Things CEOs Need to Know About Design
10 Things CEOs Need to Know About Design 10 Things CEOs Need to Know About Design
10 Things CEOs Need to Know About Design
 
презентация кп тутбери
презентация кп тутберипрезентация кп тутбери
презентация кп тутбери
 
Beowulf
BeowulfBeowulf
Beowulf
 
Маркетинг план юст
Маркетинг план юстМаркетинг план юст
Маркетинг план юст
 
Minimal pairs clothes
Minimal pairs   clothesMinimal pairs   clothes
Minimal pairs clothes
 
Aef4 12
Aef4 12Aef4 12
Aef4 12
 
Sentença do Tribunal da Itália sobre Pizzolato
Sentença do Tribunal da Itália sobre PizzolatoSentença do Tribunal da Itália sobre Pizzolato
Sentença do Tribunal da Itália sobre Pizzolato
 
Being business minded
Being business mindedBeing business minded
Being business minded
 
Comicus-Markedsføring-2015
Comicus-Markedsføring-2015Comicus-Markedsføring-2015
Comicus-Markedsføring-2015
 
Как не испортить праздник
Как не испортить праздникКак не испортить праздник
Как не испортить праздник
 
Modul I/O by MRobbyF
Modul I/O by MRobbyFModul I/O by MRobbyF
Modul I/O by MRobbyF
 
Tugas Praktikum Basis Data
Tugas Praktikum Basis DataTugas Praktikum Basis Data
Tugas Praktikum Basis Data
 
Lifestyle unit 6
Lifestyle unit 6Lifestyle unit 6
Lifestyle unit 6
 
Comicus the greatest-2015
Comicus the greatest-2015Comicus the greatest-2015
Comicus the greatest-2015
 
Roditelska noemvri 2014
Roditelska noemvri 2014Roditelska noemvri 2014
Roditelska noemvri 2014
 
3 concurrencycontrolone
3 concurrencycontrolone3 concurrencycontrolone
3 concurrencycontrolone
 
Multimedia01
Multimedia01Multimedia01
Multimedia01
 

Ähnlich wie Things you should know about WordPress (but were always too afraid to ask): WordCamp Raleigh 2014

WordPress Customization and Security
WordPress Customization and SecurityWordPress Customization and Security
WordPress Customization and Security
Joe Casabona
 
Best practices-wordpress-enterprise
Best practices-wordpress-enterpriseBest practices-wordpress-enterprise
Best practices-wordpress-enterprise
Taylor Lovett
 

Ähnlich wie Things you should know about WordPress (but were always too afraid to ask): WordCamp Raleigh 2014 (20)

Alice Phieu - WordPress For Beginners
Alice Phieu - WordPress For BeginnersAlice Phieu - WordPress For Beginners
Alice Phieu - WordPress For Beginners
 
Extending & Scaling | Dallas PHP
Extending & Scaling | Dallas PHPExtending & Scaling | Dallas PHP
Extending & Scaling | Dallas PHP
 
2015 rubyconf - 百大媒體網站從 Wordpress 到 Rails 的大小事
2015 rubyconf - 百大媒體網站從 Wordpress 到 Rails 的大小事2015 rubyconf - 百大媒體網站從 Wordpress 到 Rails 的大小事
2015 rubyconf - 百大媒體網站從 Wordpress 到 Rails 的大小事
 
WordPress Customization and Security
WordPress Customization and SecurityWordPress Customization and Security
WordPress Customization and Security
 
NEPA BlogCon 2013 - WordPress Customization & Security
NEPA BlogCon 2013 - WordPress Customization & SecurityNEPA BlogCon 2013 - WordPress Customization & Security
NEPA BlogCon 2013 - WordPress Customization & Security
 
Everything WordPress
Everything WordPressEverything WordPress
Everything WordPress
 
Developing Complex WordPress Sites without Fear of Failure (with MVC)
Developing Complex WordPress Sites without Fear of Failure (with MVC)Developing Complex WordPress Sites without Fear of Failure (with MVC)
Developing Complex WordPress Sites without Fear of Failure (with MVC)
 
Best Practices for Building WordPress Applications
Best Practices for Building WordPress ApplicationsBest Practices for Building WordPress Applications
Best Practices for Building WordPress Applications
 
The WordPress Way
The WordPress WayThe WordPress Way
The WordPress Way
 
WordCamp Greenville 2018 - Beware the Dark Side, or an Intro to Development
WordCamp Greenville 2018 - Beware the Dark Side, or an Intro to DevelopmentWordCamp Greenville 2018 - Beware the Dark Side, or an Intro to Development
WordCamp Greenville 2018 - Beware the Dark Side, or an Intro to Development
 
Faster WordPress Workflows
Faster WordPress WorkflowsFaster WordPress Workflows
Faster WordPress Workflows
 
Demystifying WordPress
Demystifying WordPressDemystifying WordPress
Demystifying WordPress
 
WordPress Complete Tutorial
WordPress Complete TutorialWordPress Complete Tutorial
WordPress Complete Tutorial
 
Wordpress beyond blogging
Wordpress beyond bloggingWordpress beyond blogging
Wordpress beyond blogging
 
Wordpress Beyond A Blog Word Camp Toronto08
Wordpress Beyond A Blog Word Camp Toronto08Wordpress Beyond A Blog Word Camp Toronto08
Wordpress Beyond A Blog Word Camp Toronto08
 
WordCamp Ireland - 40 tips for WordPress Optimization
WordCamp Ireland - 40 tips for WordPress OptimizationWordCamp Ireland - 40 tips for WordPress Optimization
WordCamp Ireland - 40 tips for WordPress Optimization
 
DrupalCon Austin - Absolute Beginner's Guide to Drupal
DrupalCon Austin - Absolute Beginner's Guide to DrupalDrupalCon Austin - Absolute Beginner's Guide to Drupal
DrupalCon Austin - Absolute Beginner's Guide to Drupal
 
Best Practices for WordPress
Best Practices for WordPressBest Practices for WordPress
Best Practices for WordPress
 
Best practices-wordpress-enterprise
Best practices-wordpress-enterpriseBest practices-wordpress-enterprise
Best practices-wordpress-enterprise
 
Agile Wordpress
Agile WordpressAgile Wordpress
Agile Wordpress
 

Kürzlich hochgeladen

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 

Kürzlich hochgeladen (20)

08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 

Things you should know about WordPress (but were always too afraid to ask): WordCamp Raleigh 2014

  • 1. THINGS YOU SHOULD KNOW ABOUT WORDPRESS (but were always afraid to ask) Power Users Track WordCamp Raleigh 2014 Saturday, November 8th, 2014 Michael McNeill - @michaelrmcneill #wcraleigh
  • 2. ABOUT ME • Developer and Support Engineer in ITS Web Services at the University of North Carolina at Chapel Hill, where I help to manage two HUGE multisite networks that operate a total of almost 8,500+ sites. • Owner and Developer at MRMcDEV, Inc. my personal consulting company. • Co-Curator (Executive Director) of TEDxUNC, a non-profit organization dedicated to bringing “Ideas Worth Spreading” to Carolina. • I’ve been using WordPress for over 5 years now, and I use it for almost all my client projects. • I’ve worked on exciting and wide ranging projects, such as Black Enterprise Magazine, Mackay Communications, WiredHoods, smallbiztechnology.com, ALOHA, and MAXI Promotion and Records. I’ve also contracted for DRS Technologies, the United States Department of the Defense, and numerous other companies. @michaelrmcneill #wcraleigh
  • 3. A QUICK ROADMAP… 1. The WordPress APIs - What they are, how to find them, and how to use them. 2. The WordPress Template Hierarchy - What it is, which file generates a certain type of page, and how to use it to your advantage. 3. The WordPress Database - What is stored there, why it is stored there, how is it stored there, and how should you properly use the data inside it. 4. A few “tricks of the trade” - Version Control and Vagrant @michaelrmcneill #wcraleigh
  • 4. THE WORDPRESS CODEX @michaelrmcneill #wcraleigh
  • 5. BOOKMARK IT! http://codex.wordpress.org @michaelrmcneill #wcraleigh
  • 6. WHAT IS IT? The WordPress Manual written for all users, Designers and Developers alike. @michaelrmcneill #wcraleigh
  • 7. USE IT & IMPROVE IT. When you first have a question, go to the Codex first. The Codex is a living document, and anyone with a WordPress.org account can edit it and improve it. If you see something out of date, or flat out wrong, update it. @michaelrmcneill #wcraleigh
  • 8. THE WORDPRESS APIs @michaelrmcneill #wcraleigh
  • 9. WHAT’S AN API? • APIs are Application Programming Interfaces. • Think about it like this, APIs are basically a contract between two things stating: "If you tell me this, I will do this.” @michaelrmcneill #wcraleigh
  • 10. WHAT DO THE WORDPRESS APIs DO? • They help you do things using tools that WordPress gives you. • That makes development EASIER!! @michaelrmcneill #wcraleigh
  • 11. HOW DO I FIND THEM? • Identify what you are trying to do. • Then go to the ___________ and search for it. • If that doesn’t work, try using Google, just remember to cross-check against what the Codex says. @michaelrmcneill #wcraleigh
  • 12. HOW DO I USE THEM? • The format is basically the same across all function reference articles. • There are 3 primary sections. 1. The description of the function. 2. The parameters the function wants/needs. 3. What values, if any, the function returns. @michaelrmcneill #wcraleigh
  • 13. WORDPRESS PAGE LIFE CYCLE • The WordPress page life cycle is a combination of the events that take place from when a browser requests a page to when the server returns the rendered page to the browser. • That sounds simple, but there are a lot of things going on that get you the end result. @michaelrmcneill #wcraleigh
  • 15. WORDPRESS HOOKS • Hooks are extremely important to WordPress developers. • They enable us to literally hook into parts of the WordPress page life cycle to retrieve, insert, and modify data, and they allow us to take certain actions behind the scenes, before a user sees what is occurring. @michaelrmcneill #wcraleigh
  • 16. WORDPRESS HOOKS @michaelrmcneill #wcraleigh • Two Classifications • Actions • Actions are triggered by specific events that take place in WordPress, such as publishing a post, activating a plugin, or loading an admin screen. • For a comprehensive list of actions, check this Codex article out: http://codex.wordpress.org/Plugin_API/Action_Reference • Filters • Filters are functions that WordPress passes data through, that are primarily responsible for intercepting, managing, and returning data, before rendering or saving that data. • For a pretty comprehensive list of filters, check this Codex article out: http://codex.wordpress.org/Plugin_API/Filter_Reference
  • 17. WORDPRESS HOOKS • I’m sure you have the question, when should I use which hook? • Use actions when you want to add something to the existing page such as stylesheets, JavaScript, or send an email when an event has happened. • Use filters when you want to manipulate data coming out of the database prior to going to the browser, or coming from the browser prior to going into the database. @michaelrmcneill #wcraleigh
  • 18. THE WORDPRESS PAGE TEMPLATE HIERARCHY @michaelrmcneill #wcraleigh
  • 19. WHAT IS THE TEMPLATE HIERARCHY? WordPress templates fit together like the pieces of a puzzle to generate the pages on your WordPress site. Some templates (the header and footer templates for example) are used on almost all pages, while others are used only under specific conditions. The template hierarchy decides what template file or files WordPress will use to display a certain type of page. @michaelrmcneill #wcraleigh
  • 21. LET’S LOOK AT THE BASICS @michaelrmcneill #wcraleigh
  • 22. THE NEEDS OF A THEME • To have a functioning, bare minimum theme you need two things. • style.css - A stylesheet. • index.php - An index file that will render the output of the page. @michaelrmcneill #wcraleigh
  • 27. SINGLE POST RULES @michaelrmcneill #wcraleigh 1. single-post.php 2. single.php 3. index.php
  • 28. PAGE TEMPLATE RULES 1. Custom Template defined in WP Admin 2. page-<slug>.php 3. page-<id>.php 4. page.php 5. index.php @michaelrmcneill #wcraleigh
  • 29. HOME PAGE TEMPLATE RULES • front-page.php • Settings > Reading • Static Page 1. Follows the page template rules. @michaelrmcneill #wcraleigh • Blog Page 1. home.php 2. index.php
  • 30. SINGLE CUSTOM POST RULES 1. single-<posttype>.php 2. single.php 3. index.php @michaelrmcneill #wcraleigh
  • 31. CUSTOM POST TYPE RULES 1. archive-<posttype>.php 2. archive.php 3. index.php @michaelrmcneill #wcraleigh
  • 32. CATEGORY PAGES 1. category-<slug>.php 2. category-<id>.php 3. category.php 4. archive.php 5. index.php @michaelrmcneill #wcraleigh
  • 33. TAG PAGES @michaelrmcneill #wcraleigh 1. tag-<slug>.php 2. tag-<id>.php 3. tag.php 4. archive.php 5. index.php
  • 34. AUTHOR PAGES 1. author-<nicename>.php 2. author-<id>.php 3. author.php 4. archive.php 5. index.php @michaelrmcneill #wcraleigh
  • 35. ATTACHMENT RULES 1. MIME-type.php (e.x. text.php, video.php, image.php) 2. attachment.php 3. single_attachment.php 4. single.php 5. index.php @michaelrmcneill #wcraleigh
  • 36. CODEX ARTICLE http://codex.wordpress.org/Template_Hierarchy INTERACTIVE WEBSITE! http://wphierarchy.com/ @michaelrmcneill #wcraleigh
  • 38. WORDPRESS DATA • A WordPress website consists of three main elements: • The WordPress installation itself • The contents of the wp-content directory which includes the themes, plugins and uploads • The database, where all the content is stored. @michaelrmcneill #wcraleigh
  • 39. TYPES OF WORDPRESS CONTENT @michaelrmcneill #wcraleigh • posts • pages • custom post types • attachments • links • menu items
  • 40. ASSOCIATED DATA (POSTMETA) • categories • tags • custom taxonomies and terms • post metadata @michaelrmcneill #wcraleigh
  • 41. OTHER TYPES OF CONTENT @michaelrmcneill #wcraleigh • widgets • options • users • sites (for multisite)
  • 43. A FEW NOTES… • In the next few slides, I’m using the wp_ prefix by default. You can change this (and you might have), but the concepts are the same. • A multisite installation will have some extra tables. I haven't included those here as that's outside the scope of this presentation. @michaelrmcneill #wcraleigh
  • 44. THE WORDPRESS DATABASE STRUCTURE Most of the tables in the WordPress database are linked to one or more other tables via a specific field. This field is generally a unique ID for each record such as a post_id. @michaelrmcneill #wcraleigh
  • 45. THE WORDPRESS DATABASE STRUCTURE TABLE DATA STORED LINKED TO wp_posts Posts, pages, attachments, revisions and menu items @michaelrmcneill #wcraleigh wp_postmeta (using post_id) wp_term_relationships (using post_id) wp_postmeta Post metadata wp_posts (using post_id)
  • 46. THE WORDPRESS DATABASE STRUCTURE TABLE DATA STORED LINKED TO wp_comments Comments @michaelrmcneill #wcraleigh wp_posts (using post_id) wp_commentmeta (using comment_id) wp_commentmeta Comment metadata wp_comments (using comment_id)
  • 47. THE WORDPRESS DATABASE STRUCTURE TABLE DATA STORED LINKED TO wp_users Users @michaelrmcneill #wcraleigh wp_posts (using post_author) wp_usermeta (using user_id) wp_usermeta Metadata for each user wp_users (using user_id)
  • 48. THE WORDPRESS DATABASE STRUCTURE TABLE DATA STORED LINKED TO @michaelrmcneill #wcraleigh wp_links (DEPRECATED!) Information related to Links wp_term_relationships (using link_id) wp_options Site settings and options (set via the Settings screens and via plugins and themes) as well as widgets None
  • 49. THE WORDPRESS DATABASE STRUCTURE TABLE DATA STORED LINKED TO wp_term_relationships Relationships between posts and taxonomies @michaelrmcneill #wcraleigh wp_posts (using post_id) wp_term_taxonomy (using term_taxonomy_id) wp_term_taxonomy Taxonomies (including categories and tags) wp_term_relationships (using term_taxonomy_id) wp_terms Your categories and tags and the terms assigned to custom taxonomies wp_term_taxonomy (using term_id)
  • 50. HOW TO USE THE WORDPRESS DB? WordPress defines a class called wpdb, which contains a set of functions used to interact with a database. Its purpose is to provide an easy to use interface with the WordPress database. @michaelrmcneill #wcraleigh
  • 51. $wpdb Methods in the wpdb() class should not be called directly. You should use the global $wpdb object instead. @michaelrmcneill #wcraleigh
  • 52. A LARGE WARNING Any function that executes SQL queries, can be vulnerable to SQL injection attacks. To prevent that, you should escape all SQL. Make sure to review the ______ to double-check if the function you plan to use escapes SQL for you or leaves it un-escaped! @michaelrmcneill #wcraleigh
  • 53. TRICKS OF THE TRADE @michaelrmcneill #wcraleigh
  • 54. VAGRANT AND VVV http://vagrantup.com https://github.com/Varying-Vagrant-Vagrants/VVV A great tutorial: http://tangrufus.com/start-wordpress- development-varying-vagrant-vagrants/ GIT AND GITHUB Great intro guide and cheat sheet: http:// rogerdudler.github.io/git-guide/ GitHub: https://github.com Deploy (Automated Deployment): https:// www.deployhq.com @michaelrmcneill #wcraleigh