~/talk

Database Interactions with WP_Query and $wpdb

Talkat WordCamp Asheville 2015 · 2015-07-25..07-26· [wordpress, databases]
links:none on file
slides:none on file

Shows how to use the global $wpdb methods like get_var, get_row, get_col, get_results and the prepare method to safely run SQL, plus properties (num_rows, rows_affected, insert_id) and table prefix usage. Demonstrates WP_Query loops that must call wp_reset_query or wp_reset_postdata to restore the global post object, builds a WP_Query for the ten most recent posts, and a meta_query filtering for 15 posts with a featured image via meta_query '_thumbnail_id'. Covers when to use get_posts or $wpdb instead of WP_Query.

AI-written summary · about

  1. 0:00Intro
  2. 0:25Jonathan Daggerhart
  3. 1:12What is a database?
  4. 1:47Let's build our own database table!
  5. 2:13Simple Form Submissions Table
  6. 4:12What is $wpdb?
  7. 6:45$wpdb SELECT Methods
  8. 7:43SELECT example: get_row()
  9. 8:29SELECT example: get_results()
  10. 9:46Dynamic Data: Always prepare()
  11. 12:03One more prepare() for the road
  12. 12:25Other $wpdb Methods
  13. 13:42Important $wpdb properties
  14. 15:40Using the prefix property
  15. 16:14Using the core table names
  16. 16:45$wpdb - Questions?
  17. 19:50WP_Query() & global $wp_query
  18. 20:43Why use WP_Query()
  19. 21:56Exploring the Main Loop
  20. 22:38These two loops are equivalent
  21. 24:28Implications of replacing the global $post object
  22. 25:44Enter wp_reset_query()
  23. 26:20Complete WP_Query() Loop
  24. 27:03Simple WP_Query() arguments
  25. 28:07Other arguments
  26. 29:49Ex1: Working WP_Query() and Loop
  27. 30:36Ex1: SQL generated by WP_Query()
  28. 33:42query_posts() & get_posts()
  29. 37:19WP_Query() Questions?
~/search
type to search 8,222 conferences, 162,397 speakers and 219,688 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
← →
on a talk: 5 seconds back / forward
0–9
on a talk: jump to 0%–90% of the recording
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.