Parsing strange v4

  • View

  • Download

Embed Size (px)



Text of Parsing strange v4

  • Parsing Strange:URL to SQL to HTML
    Hal Stern
    headshot by Richard Stevens
  • Why Do You Care?
    Database performance = user experience
    A little database expertise goes a long way
    Taxonomies for more than sidebar lists
    Custom post types
    WordPress as a powerful CMS >> blog
    Change default behaviors
    Defy the common wisdom
    Integrate other content sources/filters
    WordCamp Philly 2010
  • Flow of Control
    Web server URL manipulation
    Real file or permalink URL?
    URL to query variables
    What to display? Tag? Post? Category?
    Query variables to SQL generation
    How exactly to get that content?
    Template file selection
    How will content be displayed?
    Content manipulation
    WordCamp Philly 2010
  • Whose File Is This?
    User URL request passed to web server
    Web server checks.htaccessfile
    WP install root
    Other .htaccessfiles may interfere
    Basic rewriting rules:If file or directory URL doesnt exist, start WordPress via index.php
    WordCamp Philly 2010

    RewriteEngine On
    RewriteBase /whereyouputWordPress/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]

  • Example Meta Fail: 404 Not Found
    Access broken image URLs for unintended results: no 404 pages!myblog/images/not-a-pic.jpg
    Web server cant find file, assumes its a permalink, hands to WP
    WP cant interpret it, so defaults to home
    WordCamp Philly 2010
    myblog/wp-content (etc)
  • What Happens Before The Loop
    Parse URL into a query
    Set conditionals & select templates
    Execute the query & cache results
    Run the Loop:
    WordCamp Philly 2010
  • Examining the Query String
    SQL passed to MySQL in WP_Query objects request element
    Brute force: edit theme footer.phpto see main loops query for displayed page
    WordCamp Philly 2010