Ce diaporama a bien été signalé.
Nous utilisons votre profil LinkedIn et vos données d’activité pour vous proposer des publicités personnalisées et pertinentes. Vous pouvez changer vos préférences de publicités à tout moment.

WordPress Theme Development: Part 2

459 vues

Publié le

Part 2 in a series on WordPress custom theme development

Publié dans : Internet
  • Soyez le premier à commenter

  • Soyez le premier à aimer ceci

WordPress Theme Development: Part 2

  1. 1. WordPress Theme Development Part II
  2. 2. Who am i? ● Owner of QC Creative, a local digital marketing and web development agency ● Web developer for over 10 years ● Since 2010, 90% of projects have been in WordPress ● @joshleecreates
  3. 3. Quick Review
  4. 4. PHP Basics PHP allows logic operations with variables: $x = 1; $y = 2; $z = $x + $y; And with functions: echo( ‘Hello, World’ ); $post_title = get_post_title();
  5. 5. PHP Basics Conditionals: $x = true; if( $x == true ) { echo( ‘x is true’); } x is true Loops: $x = 0; while( $x <= 10 ) { echo( ‘x is: ‘ . $x ); } x is: 0 x is: 1 x is: 2 ...
  6. 6. Template Tags Template tags allow you to use a small PHP snippet to inject values from your WordPress database into a page the_title(); the_content(); the_excerpt(); the_post_thumbnail();
  7. 7. Output or retrieve data `the_` tags output content directly into the page: <h1> <?php the_title(); ?> </h1> `get_` tags retrieve values which can be manipulated first: <h1> <?php $title = get_the_title(); echo( $title ); ?> </h1>
  8. 8. Conditional Tags `is_` template tags return a boolean (true/false) value, useful for conditional statements: is_single(); is_page(); is_category(); is_page( ‘about-us’ );
  9. 9. The Template Hierarchy WordPress determines what kind of view is being requested, and combines the content for that view with a specific template (PHP file) from the theme. The “Template Hierarchy” determines which PHP template is used for which views.
  10. 10. The Template Hierarchy http://codex.wordpress.org/Template_Hierarchy
  11. 11. Anatomy of a Request How does WordPress build a page?
  12. 12. How does WordPress build a page? 1. User requests page 2. WP initialized 3. Plugins initialized 4. Theme initialized 5. Query type identified 6. Template identified And finally… The page is rendered by processing the chosen template together with actions and filters
  13. 13. “Theme Initialized” = functions.php ● functions.php is the first part of the theme to get run ● It is always run after plugins are initialized
  14. 14. Common Functions ● Enqueue scripts and styles ● Modify queries for specific pages ● Modify plugin or WP core behavior (actions) ● Modify plugin or WP core output (filters) ● Declare theme support ● Include other PHP libraries
  15. 15. What is Theme Support?
  16. 16. What is theme support? ● add_theme_support() ● Tells WP which features your theme can support ● E.g.: featured images, HTML5 markup, etc. ● http://codex.wordpress.org/Function_Refe rence/add_theme_support
  17. 17. Hooks, Actions, & Filters Doing it the WordPress way
  18. 18. What are Hooks? A hook is an anchor associated with a specific event within WordPress E.g.: ● A page is requested ● A query is run ● the_content() is output for a post or page ● A user logs in
  19. 19. What are actions? Filters? Actions & Filters are functions that you define, and attach to a specific hook.
  20. 20. Which means… We can tell WordPress: ● Whenever doing X, first do Y ● E.g.: o Whenever loading the blog homepage, first add my custom post type to the query