Divi WordPress Theme
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

WordPress fix Reply To: wp_query class

Discussion in 'Misc WordPress Requests' started by Jacob Peattie, Apr 5, 2018.

  1. Jacob Peattie

    Guest

    Reply To: wp_query class, by Jacob Peattie

    Pretty much every WordPress template needs to use the have_posts() and the_post() functions of the main query to work, so rather than making developers do this:


    global $wp_query;

    while ( $wp_query->have_posts() ) : $wp_query->the_post();

    endwhile;


    The have_posts() and the_post() functions are made available as shorter ways to deal with the main query:


    while ( have_posts() ) : the_post();

    endwhile;


    It’s sort of a form of ‘syntactic sugar’, just to make development a bit easier.

    Reply To: wp_query class
     
    #1

Share This Page

Monarch Social Sharing Plugin