• Resolved kreso777

    (@kreso777)


    I have custom field value named “rating” which is a numerical value between 0 – 100.
    Is it possible to select and display, say, all the posts with numerical value larger than 80?

Viewing 1 replies (of 1 total)
  • Thread Starter kreso777

    (@kreso777)

    Sorry for the ambiguous topic title, too late for changing.

    Anyways, after 2 hours of testing and googling, finally managed to get it work. For the future reference, if anyone stumbles up here while googling here goes:

    <?php
    $myposts = get_posts('meta_key=CUSTOM_VALUE&meta_compare=>&meta_value=20&orderby=meta_value&ordrer=ASC');
    foreach($myposts as $post) :
        setup_postdata($post); ?>
    <li><a href="<?php the_permalink(); ?>"><?php the_title();?></a> <?php echo get_post_meta($post->ID, 'CUSTOM_VALUE', true); ?></li>
    <?php endforeach; ?>
Viewing 1 replies (of 1 total)
  • The topic ‘Custom fields’ is closed to new replies.