xxxxxxxxxx
<?php
$args = array(
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => -1,
'orderby' => 'title',
'order' => 'ASC',
);
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
?>
<h2><?php echo get_the_title(); ?></h2>
<?php
endwhile;
wp_reset_postdata();
?>
xxxxxxxxxx
if ( ! defined('ABSPATH') ) {
/** Set up WordPress environment */
require_once( dirname( __FILE__ ) . '/wp-load.php' );
}
global $wpdb;
$results = $wpdb->get_results( "SELECT * FROM {$wpdb->prefix}options WHERE option_id = 1", OBJECT );
xxxxxxxxxx
<?php
// The Query
$the_query = new WP_Query( $args );
// The Loop
if ( $the_query->have_posts() ) {
echo '<ul>';
while ( $the_query->have_posts() ) {
$the_query->the_post();
echo '<li>' . get_the_title() . '</li>';
}
echo '</ul>';
} else {
// no posts found
}
/* Restore original Post Data */
wp_reset_postdata();
xxxxxxxxxx
<?php
$display_posts = -1; // dispay all posts
$args = array(
'post_type' => 'post',
'posts_per_page' => $display_posts,
// 'orderby' => 'date',
// 'order' => 'DESC',
'post_status' => 'publish',
);
$QUERY = new WP_Query($args);
if($QUERY->have_posts()):
while ($QUERY->have_posts()): $QUERY->the_post();
echo "<h2>".get_the_title()."</h2>";
endwhile; wp_reset_query();
endif;
?>