• happyfejs

    (@happyfejs)


    Hello, I recently started looking on wordpress and trying to figure out how the querys works. It seems like the easiest way to get a post is like below?

    $args = array( 'numberposts' => 1, 'category' => 13, 'orderby' => 'rand' );
                $rand_posts = get_posts( $args );
                foreach( $rand_posts as $post ) : ?>
                   <h2 style="margin:0px;"><?php echo the_title(); ?></h2>
                <?php
                endforeach; ?>

    But if I want to add to $args that I only want to show the posts where my own field for example phone number is filled out, how do I do that?
    For printing the row out on the page I use the follow line, but I can’t figure out how to put it into the $args array.

    get_post_meta($post->ID, 'phonenumber', true);

    Thanks!

Viewing 1 replies (of 1 total)
  • esmi

    (@esmi)

    I only want to show the posts where my own field for example phone number is filled out

    Assuming that this a custom field, see this Codex section.

Viewing 1 replies (of 1 total)
  • The topic ‘$args WHERE "own field" = "something"’ is closed to new replies.