Support » Fixing WordPress » Display posts and pages if custom field is present

  • Heya all

    Ive been playing with some code i found on the forums that displays and links to posts if they have a custom field set. I am trying to acheive the same thing however i would like the list to include pages aswell. Im not to sure how to go about this though, can anyone help? The code i currently have is below, its a straight lift from another thread i found.

      $postslist = get_posts('numberposts=-1&order=ASC&orderby=title&meta_key=restlist');
     foreach ($postslist as $post) :
    $customPostID = get_post_custom($post->ID);
    if(isset($customPostID['restlist'])) :
    echo '<li><a href="' . get_permalink() . '">' . $customPostID['restlist'] . '</a></li>';

    Any help will be much apreciated.


Viewing 1 replies (of 1 total)
  • Missed the opening <ul> to the code, not that it makes a vast difference just letting anyone know if they were going to play with the code.

Viewing 1 replies (of 1 total)
  • The topic ‘Display posts and pages if custom field is present’ is closed to new replies.