Answers for "wordpress meta_query"

PHP
1

wp_query get custom post type

<?php    
  	   $args = array(  
      'post_type' => 'custom_type',
      'post_status' => 'publish',
      'posts_per_page' => 8, 
      'orderby' => 'title', 
      'order' => 'ASC', 
          );

  $loop = new WP_Query( $args ); 

  while ( $loop->have_posts() ) : $loop->the_post(); 
      print the_title(); 
      the_excerpt(); 
  endwhile;

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