Query & Loop
Query & Loop
Standard-Loop
<?php
if (have_posts()):
while (have_posts()):
the_post();
?><h1><?php the_title(); ?></h1><?php
the_content();
endwhile;
else:
?><h1>Nothing Found</h1><?php
endif;
?>
wp_query
<?php
/* Variant 1 */
global $query_string;
$posts = query_posts($query_string);
/* Variant 2 */
$posts = query_posts();
/* DEFAULT LOOP */
wp_reset_query();
?>
Class WP_Query()
<?php
$query = new WP_Query($args);
while($query->have_posts()) :
$query->the_post();
<h1><?php the_title(); ?></h1><?php
the_content();
endwhile;
wp_reset_postdata();
?>
Code-Refernez