My new advanced WordPress course: https://www.udemy.com/become-a-wordpress-developer-php-javascript/?couponCode=YOUTUBEDEAL
My new beginner WordPress course: https://www.udemy.com/wordpress-for-beginners-create-a-website-blog-step-by-step/?couponCode=YOUTUBEDEAL

In this lesson we learn how to use page templates and conditional logic to apply different layouts to different WP pages.

To view a complete list of the WordPress lessons in sequential order visit:
http://learnwebcode.com/learn-wordpress/

Link to download .zip of theme files as shown in this video (note: this is not a “complete” WordPress theme yet and this download is only intended for educational purposes to dissect and review):

http://learnwebcode.com/wordpress-page-templates-tutorial/

Sign up for my newsletter to receive periodic webDev tips, tricks, resources and coupons. Join the list at http://learnwebcode.com/

Follow me on Twitter for updates and cat pics:
https://twitter.com/learnwebcode

source

49 Comments

  1. I have basically 6 pages including homepage, all have save navigation menu, but their text colour is also same on every page which is what i need to change, as i need to change every other nav menu text color white if its not homepage. I have used condition is_front_page(), but seems css is not applying to all pages except homepage(index.php).

  2. Hey its not working as you showed. I added the templatename.php to the theme folder. When I go to edit the page. I do not see the same in the page attribute. The dropdown is missing. I tried few other videos but I found this is bug is the pervious version of WP.

    I am using the WP 5.1.1.

    Can you help please?

  3. Instant Wordpess Theme To Match Your Existing Website Design! (view mobile)
    World's First Automatic And Online HTML To WordPress Converter. Theme Matcher Uses A Regular Site To Instantly And Effortlessly Create A Matchcing WordPress Theme. This Is The Only Product Of It's Kind @t

  4. I have one big problem and I don't know how to repair it. When I have created some posts by wordpress dashboard I have them in posts list but they don't appear on my web page. Additionally i can't change their appearance by CSS file because I don't even know did those posts exist. Maybe somebody have solution for my problem I would be gratefull.

  5. i have real estate website and when i add new properties in page attributes i get parent and in the drop down list of page parent i get a list of recently posted properties instead of menus or pages, how i can edit this parent drop down list

  6. Clearfix explanation – if you're like me then you're probably wondering what this block of code is all about and why it will break your layout if you neglect it:

    .clearfix:before, .clearfix:after { content: ""; display: table; }

    .clearfix:after { clear: both; }

    .clearfix { *zoom: 1; }

    To the best of my understanding, this block of code is sort of a little hack to get the CSS layout to behave the way that you think it should. In page-portfolio.php, the first line inserts an empty table before and after the container and the second line prohibits any element from being floated to the left or right of the invisible table. This effectively just keeps the elements that are being inserted by get_footer() from spilling over into your page content. Tables are generally sturdier elements than normal divs for positioning in html/css so surrounding elements are less likely to intrude in their space. As for the last line, I'm not exactly sure how it's functioning in this context, but an asterisk (*) preceding a property is just a CSS hack that will force some older browsers (namely older versions of IE) to ignore a property that they don't support.

    I would normally opt to just lay everything out in a table or use the 'display: table' property for my container div to avoid having to add hidden corrections, but perhaps the reason he chose to do it this way in this video is that the markup seems the most quick and intuitive to an html/css beginner and this is a tutorial on WordPress theme development, not the positioning rules of CSS.

    If you have anything to add please let me know! I'm still learning too 🙂 Thanks for the videos! I'm a fairly experienced programmer but totally new to WordPress, and they've been immensely helpful.

  7. Hello. I am unable to output post title and content using the "the_title();" and "the_content();" function. I have created a newf file named page-blog.php which corresponds to the page blog. You kind support in this regard will help me out a lot. Thanks.

  8. When I add the page template (page-11.php in my case) the footer goes full-width. Do you know why this is happening? Do I need to create a page template specifically for the footer as well? The video is going great by the way. I just had this quick question. Thanks!

  9. Dear Sir, thank you a lot for all of your massive work and efforts, hope to find PHP learning course sooner, I've tried to participate to your course of "Become a wordpress developer" but I have issues not to complete the payment method because I'm from Syria 🙁 , any suggestion will be highly appreciated. However, I'm subscribed and follow all of your lessons, God bless you.

  10. Hey Man, you're SICK….that aside…..How do I create different templates for different pages on my wordpress website so that I can use ELEMENTOR to import these templates.Or am I thinking of this in a wrong manner.?

    Thanks in advance!

  11. Loving your tutorials, great videos and brilliantly explained!!

    I have a question on the "disclaimer" text at 10:36 …Supposing a client wanted to change the text in a box like this from time to time, obviously you wouldn't want them messing around with PHP files, so is it possible to include this text as HTML in another page, and include that page inside the box, i.e. like a kind of iframe?

  12. i basically overwrited all my files with yours that were included in a zip file regarding the previous lesson.

    But the "small" changes made offscreen arent showing up, its just displaying the website as it was how i written it.

    At first i thought somehow wordpress is not connecting my files with the website as it changed nothing when i for example increased font size of the body but when i delete all the files theres no website, so they are indeed connected.

    What can be the problem that its not changing anything?

  13. FYI: I wasn't able to change my CSS until I realized that SOMETIMES YOUR BROWSER DOESN'T CLEAR YOUR CACHE MEMORY when you refresh your page. So, although i was refreshing the page, it was still using the previously saved version of the CSS file. I cleared my history and it worked. Hope this helps someone

  14. why does the if statement syntax look so odd. I'm very new to php but I'm used to seeing something like <?php
    if ($a > $b)
    echo "a is bigger than b";
    ?>

Leave A Reply

Please enter your comment!
Please enter your name here