WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Template with Custom Select Query (2 posts)

  1. jacob_boetter
    Member
    Posted 8 years ago #

    I am trying to make a template that shows a custom select query. It all works pretty neat so far, but one thing is still wrong: It shows everything, but the comments (The meta data under the post, ala "32 Comments"

    This is my code:

    <?php
    /*
    Template Name: High Risks
    */
    ?>

    <?php get_header();

    $query="SELECT * FROM wp_questions";
    $result=mysql_query($query);
    $p=array();
    while ($row=mysql_fetch_assoc($result)) {
    $p[count($p)]=$row['post'];
    }

    $p="SELECT wposts.* FROM $wpdb->posts wposts WHERE (wposts.ID = ".implode(" OR wposts.ID = ",$p).") ORDER BY wposts.post_date DESC";
    $pageposts = $wpdb->get_results("".$p."", OBJECT);

    ?>
    <div id="content" class="narrowcolumn">

    <?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> <script type="text/javascript">slvShowNewIndicator(<?php print(mysql2timestamp($post->post_date)); ?>);</script></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 &raquo;'); ?>
    </div>

    <p class="postmetadata">Posted by <?php the_author_firstname(); ?> <?php the_author_lastname(); ?> 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.
    <?php include (TEMPLATEPATH . "/searchform.php"); ?>
    <?php endif; ?>

    </div>

    <?php get_sidebar(); ?>

    <?php get_footer(); ?>`

  2. jacob_boetter
    Member
    Posted 8 years ago #

    Fixed by using comments_number(); instead of comments_popup_link();

    Weird bug.

Topic Closed

This topic has been closed to new replies.

About this Topic