Need assistance forming a query to return an array from Custom Field values

I need help with code to query all posts that have the Custom Field Szerz? and return the values of all queried posts into an array.

  • Predrag Dubajic
    • Support

    Hey Bela,

    Hope you're doing well :slight_smile:

    Something like this should do the trick for you:

    global $wp_query;
    $args = array(
      'post_type'      => 'thesis',
      'posts_per_page' => -1,
      'post_status'    => 'publish',
      'meta_query'     => array(
          'key'     => 'ct_Szerz_text_66a9'
    // The Query
    $myquer = new WP_Query( $args );
    $temp_query = $wp_query;
    $wp_query   = NULL;
    $wp_query   = $myquer;
    <?php if ( $myquer->have_posts() ) : ?>
    <?php while ( $myquer -> have_posts()) : $myquer -> the_post(); ?>
            <h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
            <div class="thesis_content"><?php the_content(); ?></div>
            <?php echo do_shortcode('[custom_fields_block]'); ?>
    <?php endwhile;

    Let us know if that's what you wanted to do :slight_smile:

    Best regards,

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.