WordPress.org

Forums

Trouble with Archive Page (2 posts)

  1. nifft
    Member
    Posted 2 years ago #

    I'm sure there's a simple fix, but I can't find the problem.

    I'm using the Thesis theme.

    I cut/pasted code for an Archive Page into my Custom_Functions.php file that includes links to the last 15 posts.

    It seems to be treating the last in the list as an actual post, and showing tags and comments from the last link in the list at the bottom of the page.

    It can be seen at:
    http://www.morebettersmarts.com/archives-6/

    The code from the php file is below. Any help is greatly appreciated.

    Thanks

    /* ----------------------------------
    CUSTOM ARCHIVE PAGE
    ---------------------------------- */

    function my_archive() {
    ?>
    <div class="archive">
    <table border="0">
    <tr>
    <td width="50%" valign="top">
    <h2>Categories</h2>

      <?php wp_list_categories('orderby=name'); ?>

    </td>
    <td width="50%" valign="top">
    <h2>Tags</h2>
    <?php wp_tag_cloud('smallest=8&largest=20'); ?>
    </td>
    </tr>
    </table>

    <h2>Last 15 Posts</h2>

    <?php
    $my_query = new WP_Query('post_type=post&nopaging=1');
    if($my_query->have_posts())
    {
    echo '

    ';
    }
    ?>

    <h2>By Month</h2>
    <p><?php wp_get_archives('type=monthly&format=custom&after= |'); ?></p>
    </div>
    <?php
    }
    remove_action('thesis_hook_archives_template', 'thesis_archives_template');
    add_action('thesis_hook_archives_template', 'my_archive');

  2. markcallen
    Member
    Posted 2 years ago #

    Hi nifft

    Try adding a call to wp_reset_query(); at the end of your loop for $my_query.

    Hope this helps.

Topic Closed

This topic has been closed to new replies.

About this Topic