Answers for "meta_query wordpress"

PHP
0

wordpress meta_query relation

$results = query_posts( array(
    'post_type' => 'event_id',
    'meta_query' => array(
        'relation' => 'AND',
        array(
            'relation' => 'OR',
            array(
                'key' => 'primary_user_id',
                'value' => $user_id
            ),
            array(
                'key' => 'secondary_user_id',
                'value' => $user_id
            )
        ),
        array(
            'key' => 'date',
            'value' => array( $start_date, $end_date ),
            'type' => 'DATETIME',
            'compare' => 'BETWEEN'
        )
    )
) );
Posted by: Guest on July-08-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
0

meta_value wordpress

$meta_query_args = array(
    'relation' => 'OR', // Optional, defaults to "AND"
    array(
        'key'     => '_my_custom_key',
        'value'   => 'Value I am looking for',
        'compare' => '='
    )
);
$meta_query = new WP_Meta_Query( $meta_query_args );
Posted by: Guest on November-29-2020

Browse Popular Code Answers by Language