Chapter 2 – WordPress Basics

I appreciated the bird’s eye view of the default WordPress directory and database structure in this chapter and took to heart the advice to never, ever, ever, ever hack the core code. There is always a way to extend or modify WordPress elegantly.

The 3 major directories highlighted are:

  • /wp-admin which contains core directories and files for managing the WordPress admin area and a file (to be discussed later) that processes all AJAX requests.
  • /wp-includes which contains various core directories and files for WordPress functionality.
  • /wp-content with the subdirectories developers will typically work with – /themes, /uploads/ and /plugins. Everything in this directory is also neatly backed up.

The WordPress Database

As a PHP developer, I have vast experience with MySQL and found the next section very informative in orienting me around the WordPress Database. What is particularly useful about this section is the coupling of the databases with the functions in /wp-includes that provide an interface to manipulate data in these table. In addition, these functions have an explanation for each variable and usage. I read each one of them carefully but will only provide one detailed example.

  • wp_options – sitewide data storage
    • option_id bigint(20)
    • option_name varchar(64)
    • option_value longtext
    • autoload varchar(2)
      • add_option($option, $value, $deprecated, $autoload=yes)
      • update_option($option, $newvalue)
      • get_option($option, $default=false)
      • delete_option($option)
  • wp_userswp_insert_user(), wp_create_user(), wp_update_user(), get_user_by(), get_userdata(), wp_delete_user()
  • wp_usermeta
  • wp_posts – *** table that supports Custom Post Types (more on that later)
  • wp_postmeta – note that the name or “key” will be hidden from the Custom Fields UI on the edit post page if it starts with an underscore (_)
  • wp_comments
  • wp_commentsmeta
  • wp_links (to be discussed later and possible deprecated in future versions)
  • wp_terms – supports WordPress taxonomy – tags and categories
  • wp_term_taxonomy – supports taxonomy types of which tag nd category are two default ones
  • wp_term_relationship – maps a term to a post (or CPT)
Categories: WordPress