WordPress Custom Loop WP_Query Tutorial

WordPress Custom Loop WP_Query Tutorial


Learn about WP_Query and create custom loops in any WordPress theme file. Check out my “Get a Web Developer Job” course:

To learn about everything that WP_Query is capable of check out the official WordPress documentation:

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):

To view a complete list of the WordPress lessons in sequential order visit:

Want to share the WordPress website that you’ve been creating on your computer with the world? Learn about the web host I use and how you can get a domain + hosting for .95 a month:

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

Follow LearnWebCode on Twitter for resources and updates:

37 Comments

37 Replies to “WordPress Custom Loop WP_Query Tutorial”

  1. Just discovered these – they’re great. Thanks for the effort.

    Will you by any chance at some point do a tutorial on creating your own widgets?

  2. Is there a good guide you know of, that has all the main functions listed? Kinda like a cheat sheet.

  3. Nice text editor, good for identifying php code. Could u tell us the name?

  4. Nice tutorial, but I have one question. How to make one loop with custom post type (category) and normal category? How to make all in one loop?

  5. At the end of this tutorial, I just wanna say;
    Man you are awesome.

    Thank you very much,

  6. Hello, First of all i would like to thank you a lot for this wordpress theme development playlist. You deserve a good appreciation and respect for helping many beginner developers. I have developed a theme for my own sports website by learning from your tutorials. But i would like to suggest you to add videos on making the theme responsive and on adding page links(useful to see old posts when limited to 5 posts per each page). I have searched from various sources and completed my theme. I`m just suggesting so that it would be helpful for those who follow this playlist in future. Once again THANK YOU !!

  7. Really helpful tutorial and thanks a lot for it.
    How can I print the category name before printing the title of each post?

  8. <a href="”>

    <img src="/images/leaf.jpg”>

    ——————————————

    please explain

  9. Hey! I know this is an old video but I was wondering… could I create 2 different templates for those 2 columns and then call them with get_template_part? If I have my homepage structured with 6 rows, each with a different loop, wouldn that output a “cleaner” code? Is there any advantage or this just doesnt makes sense? Thanks!

  10. how embed post thumbnails (featured images) to index.php in underscores?
    (Underscores doesn’t embed post thumbnails by default to index.php in markup by php tags)

  11. thanks for tutorial before, but i have question , how you can make the button look like on the last minutes, can you make tutorial please??

  12. How can i get atom editor to do that thing where you type two matching lines of code at the same time?

  13. Sir My 2nd post is not showing

    have_posts()):

    while ($opinionPosts->have_posts()): $opinionPosts->the_post();?>

    <a href="”>

    have_posts()):

    while ($graphicPosts->have_posts()): $graphicPosts->the_post();?>

    <a href="”>

  14. I used your code, deleted the wp_reset_postdata(); and nothing changed, can you explain it briefly why and whats the purpose of it?

  15. I so wanna say thank you!
    I knew literally NOTHING about html, php and css till a week ago and now i actually am able to do sooooo much!!
    Your explanations are perfect and these videos are just so well made.
    thank you again.

  16. I’m finding myself in a pickle… not sure why this is happening… i’m working on my homepage (front-page.php) i designed it to be a 3 block scrollereach block i show the last few posts from a category.

    I followed your video and i manage to get the outputs properly but i’ve noticed that the html page doesnt load the rest of the html after the loop!

    Not sure why that is….

  17. sir how to change wp_query post width in 3 to 4 column it displays only 100% size

  18. Great tutorial. However I have a question. If I make a theme and give it to someone else. How do I know that the Opinion category is going to have the same ID in his installation?

Comments are closed.