Support » Fixing WordPress » sort by category and custom field

Viewing 4 replies - 1 through 4 (of 4 total)
  • What’s the code you are using then?

    I am using the code from that Codex page:

    <?php
    $pageposts = $wpdb->get_results("SELECT wposts.* FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta
    WHERE wposts.ID = wpostmeta.post_id AND wpostmeta.meta_key = 'tag' AND wpostmeta.meta_value = 'email' AND
    wposts.post_status = 'publish' AND wposts.post_date < NOW() ORDER BY wposts.post_date DESC", OBJECT);
    ?>
    <?php if ($pageposts): ?>
    <?php foreach ($pageposts as $post): ?>
    <?php setup_postdata($post); ?>

    <div class="post" id="post-<?php the_ID(); ?>">
    <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">
    <?php the_title(); ?></a></h2>
    <small><?php the_time('F jS, Y') ?> <!-- by <?php the_author() ?> --></small>
    <div class="entry">
    <?php the_content('Read the rest of this entry »'); ?>
    </div>

    <p class="postmetadata">Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?>
    <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></p>
    </div>
    <?php endforeach; ?>

    <?php else : ?>
    <h2 class="center">Not Found</h2>
    <p class="center">Sorry, but you are looking for something that isn't here.</p>
    <?php include (TEMPLATEPATH . "/searchform.php"); ?>
    <?php endif; ?>

    Is there a way to add to this so that it also shows posts from a certain category in addition to the postmeta restriction?

    Kaf to the rescue again!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘sort by category and custom field’ is closed to new replies.