Answers for "wordpress wp_query"

PHP
0

wordpress custom php use wp query

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 );
Posted by: Guest on July-01-2020
5

wp query

<?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();
Posted by: Guest on September-27-2020
1

wp query search

$query = new WP_Query( array( 's' => 'keyword' ) );
Posted by: Guest on December-16-2020
0

wp_query

<?php 
// the query
$the_query = new WP_Query( $args ); ?>
 
<?php if ( $the_query->have_posts() ) : ?>
 
    <!-- pagination here -->
 
    <!-- the loop -->
    <?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
        <h2><?php the_title(); ?></h2>
    <?php endwhile; ?>
    <!-- end of the loop -->
 
    <!-- pagination here -->
 
    <?php wp_reset_postdata(); ?>
 
<?php else : ?>
    <p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
<?php endif; ?>
Posted by: Guest on March-06-2021
0

WP_Query

$query = new WP_Query( array( 'author__in' => array( 2, 6 ) ) );
Posted by: Guest on August-12-2021

Code answers related to "wordpress wp_query"

Browse Popular Code Answers by Language