• Resolved andreash-1

    (@andreash-1)


    Hey guys…

    This is probably easier then I think…

    I want a custom loop that shows the latest post within one category of posts IF a certain custom field exist for that post…

    Thanks for any help and pointers!

Viewing 3 replies - 1 through 3 (of 3 total)
  • MichaelH

    (@michaelh)

    Display one post belonging to the “events” category with the custom field “party”

    <?php
    $cat_id = get_cat_ID('events');
    $args=array(
      'cat' => $cat_id,
      'meta_key'=>'party',
      'post_type' => 'post',
      'post_status' => 'publish',
      'posts_per_page' => 1,
      'caller_get_posts'=> 1
    );
    $my_query = null;
    $my_query = new WP_Query($args);
    if( $my_query->have_posts() ) {
      echo 'List of Posts';
      while ($my_query->have_posts()) : $my_query->the_post(); ?>
        <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
        <?php
      endwhile;
    }
    wp_reset_query();  // Restore global post data stomped by the_post().
    ?>

    Thread Starter andreash-1

    (@andreash-1)

    Sweet! 🙂

    Thanks a lot!

    anatizer

    (@anatizer)

    I think I have a similar question be patient with me if this doesn’t fit as I am very new to WP I am blogging a work of fiction and have started with Prologue then Chapter 1. Of course the next chapter 2 then shows up as the first thing that readers see and so on thru out about 80 chapters. Short of starting at the end of the book I can’t figure out how to post with 1st chapter 1st and all others follow in order chapters not of posting. Is there a way to do that? Also I would like to have the author’s bio show on the front page as well and have info in about but that is a link that has to be activated rather than appearing on front page Any help would be appreciated. Anatizer

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Show latest post within a category IF a certain custom field’ is closed to new replies.