Is WordPress PHP? We will look at how WP uses PHP, discuss what Template tags are and how to extend them. We will also convert a basic PHP function into a WP Plugin.
3. What is ? We’ll skip the basics and head straight to the code…. … if you’re interested you can check out Some of my other presentations later http://digibombinc.com/events
5. What you need PHP version 4.3 or greater MySQL version 4.0 or greater Creativity and Passion
6.
7.
8. Yes, I know, this is PHP Quebec… Ok, back to the code.
9. Templating How it all works If you go the default theme folder ( wp-content/themes/default ), you will see many PHP files (these are template files) and one style.css file. When you are viewing the front page, WordPress actually uses several template files to generate the page ( index.php << header.php , sidebar.php , and footer.php ).
12. Templating Let’s start with the Template System Template Tags Conditional Tags PHP Function Calls
13. Templating <?php // syntax #1: curly braces if ( condition to check ){ // code to execute if the condition is true } // syntax #2: colon and endif if ( condition to check ): // code to execute if the condition is true endif; ?> <?php if ( is_home() ): ?> <h3>Main Page</h3> <?php elseif( is_archive() ): ?> <h3>Archives Page</h3> <?php else: ?> <h3>Welcome to my blog!!</h3> <?php endif; ?> Standard PHP WordPress
14.
15.
16. Templating The Loop The Loop is used to display posts and it also lets you control what to display. Basically, The Loop checks if there are posts in your blog, while there are posts, display it, if no post found, say "Not Found".
17. Templating A complete template In this example we are using some standard Template Tags to display the title of the post the_title() and we are linking it using the_permalink() . We call use the_date() and display the_content() . Finally for fun we call link_pages() .
18. Templating Playing with the code <?php wp_list_categories('show_count=1&title_li=<h2>Categories</h2>'); ?> Most blogs display categories somewhere, usually the side bar. The easiest way to do this is with the wp_list_categories() Template Tag.
19. Templating Playing with the code <ul> <li id="categories"> <?php wp_dropdown_categories('title_li=&hierarchical=0&show_count=1&child_of=9'); ?> <script type="text/javascript"> <!-- var dropdown = document.getElementById("cat"); function onCatChange() { if ( dropdown.options[dropdown.selectedIndex].value > 0 ) { location.href = "<?php echo get_option('home'); ?>/?cat="+dropdown.options[dropdown.selectedIndex].value; } } dropdown.onchange = onCatChange; --> </script> </li> </ul> What if I wanted to display specific categories and have them in a dropdown box? * See the full tutorial at dropthedigibomb.com
20. Templating Playing with the code <?php if(is_page("landing")) : ?> <h5 class="tagline"> Hello! I'm Brendan Sera-Shriar A.K.A. <span class="blue">digibomb</span>, a freelance web designer from Montreal, Canada. </h5> <?php elseif(is_page("work") || is_page("branding") || is_page("other-projects") || is_page("client-list")) : ?> <h5 class="tagline"> I don't just build <span class="blue">websites</span> I build <span class="blue">communities</span>! </h5> <?php endif; ?> What if I wanted to display different taglines on each page? * See it in action at digibombinc.com