I have

<?php $args = array(
    'posts_per_page'   => 5,
    'offset'           => 0,
    'category'         => '',
    'orderby'          => 'post_date',
    'order'            => 'DESC',
    'include'          => '',
    'exclude'          => '',
    'meta_key'         => '',
    'meta_value'       => '',
    'post_type'        => 'ait-dir-item',
    'post_mime_type'   => '',
    'post_parent'      => '',
    'post_status'      => 'publish',
    'suppress_filters' => true ); 


    $myposts = get_posts( $args );
foreach ( $myposts as $post ) {
//print_r($post);

$key_1_value = get_post_meta($post->ID, '_ait-dir-item', true );

// check if the custom field has a value
if( ! empty( $key_1_value ) ) {
  Print_r( $key_1_value);
} 
    }

Emphasized Text Here

Member Avatar for diafol

You're using a number of user-defined functions, which really confuse the matter as you don't include them so we can see what they do. This is not your code I take it, so where did you get it?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.