Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Fledgling WordPress Developer? Learn PHP!

Fledgling WordPress Developer? Learn PHP!

Fledgling WordPress Developer? Learn PHP! (Speaker Notes) by Peter Shackelford
Published August 15, 2014 in Programming

Many people start doing things on the web at zero. Often the thing that gets them started is WordPress. You can learn a lot from template files and doing things with existing WP functions but there comes a point where actually learning PHP will do wonders for your growth towards becoming a full fledged developer.

Peter Shackelford

August 15, 2014
Tweet

More Decks by Peter Shackelford

Other Decks in Programming

Transcript

  1. The Loop <?php if ( have_posts() ) : ?> <?php

    while ( have_posts() ) : the_post(); <!-- do stuff ... --> <?php endwhile; ?> <?php endif; ?> CC image credit girlwparasol flickr
  2. What does this mean‽ array(62) { ["page"]=> int(0) ["pagename"]=> string(13)

    "meet- your-rep" ["error"]=> string(0) "" ["m"]=> string(0) "" ["p"]=> int(0) ["post_parent"]=> string(0) "" ["subpost"]=> string(0) "" ["subpost_id"]=> string(0) "" ["attachment"]=> string(0) "" ["attachment_id"]=> int(0) ["name"]=> string(13) "meet- your-rep" ["static"]=> string(0) "" ["page_id"]=> int(0)… var_dump($wp_query->query_vars);
  3. $args =array( key => value, key2 => value2, ); $args

    = array( 'post_type' => 'portfolio', 'post_status' => 'publish', ); Familiar?
  4. $args =array( key => value, key2 => value2, ); $args

    = array( 'post_type' => 'portfolio', 'post_status' => 'publish', ); Familiar?
  5. Messy elseif? Switch Case! switch ($zipcode) { case ( $zipcode

    >= $michigan->getZipmin() && $zipcode <= $michigan->getZipmax() ): echo "I am in Michigan!”; break; case ( $zipcode >= $ohio->getZipmin() && $zipcode <= $ohio->getZipmax() ): echo “I am in Ohio!”; break; } Check if $zipcode is in a state’s zip code range.
  6. 1. Create form field. 2. Show field if $_SERVER[‘REQUEST_METHOD' !=

    ‘POST' 3. Validate and sanitize $zipcode 4. Pass $zipcode into function 5. Get the template part if $_SERVER[‘REQUEST_METHOD' == ‘POST' General Steps