A different kind of Archive page

  • KeithS

    #6694

    I’m in the midst of modifying a plugin to create a archive page that lists the last 30 days of blog posts, a list of the categories on the blog, and a month by month list of the post dates of the blog with a post count beside each. After some work, I have gotten it to display with Graphene, but it outputs the lists before the page is created and then in the body of the post as well. Can anyone see a problem with the following code which would do this? Note, the tags are not set up fully, but the creation of the data is as shown in the code. I’m after the output or print error here. Blog is running current version of Graphene and WordPress 3.5.1 Thanks for any thoughts!

    <?php
    $posts = get_option("archives");
    $count_posts = wp_count_posts( 'post' );
    $count_pages = wp_count_posts( 'page' );
    $count_comments = wp_count_comments();
    $count_cats = wp_count_terms( 'category', array( 'hide_empty' => true ) );
    $count_tags = wp_count_terms( 'post_tag', array( 'hide_empty' => true ) );
    printf( __('This is the archives page of <strong>%1$s</strong>.', 'archives'),
    get_bloginfo('name'),
    sprintf( _n( '%d post', '%d posts', $count_posts->publish, 'archives' ), number_format_i18n( $count_posts->publish ) ),
    sprintf( _n( '%d page', '%d pages', $count_pages->publish, 'archives' ), number_format_i18n( $count_posts->publish ) ),
    sprintf( _n( '%d comment', '%d comments', $count_comments->approved, 'archives' ), number_format_i18n( $count_comments->approved ) ),
    sprintf( _n( '%d category', '%d categories', $count_cats, 'archives' ), number_format_i18n( $count_cats ) ),
    sprintf( _n( '%d tag', '%d tags', $count_tags, 'archives' ), number_format_i18n( $count_tags ) )
    );
    $tag_cloud = get_terms( 'post_tag' );
    if ( $tag_cloud ) :?>
    <?php endif; ?>
    <h2><?php _e('Last ' .$posts .' Posts', 'archives'); ?></h2>
    <?php query_posts('showposts=' .$posts . '''); ?>
    <ul>
    <?php
    if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    <li><?php the_time('F j, Y'); ?> - <a href="<?php the_permalink() ?>"><?php the_title(); ?></a> </li>
    <?php endwhile; endif; ?>
    </ul>
    <?php wp_reset_query(); ?>
    <h2><?php _e('Categories', 'archives'); ?></h2>
    <ul>
    <?php wp_list_categories('title_li=&hierarchical=0&show_count=1'); ?>
    </ul>
    <h2><?php _e('Monthly Archives', 'archives'); ?></h2>
    <ul><?php wp_get_archives('type=monthly&show_post_count=1'); ?>
    </ul>
    <!-- End Archives Plugin-->

    KeithS

    #35268

    Minor Update:

    Running the code as PHP within the post using exec-php plugin will produce a perfect output with no errors. I still would like to use shortcodes and a plugin however.

    Admin

    Syahir Hakim

    #35269

    Can you point us to the page where the list is printed before the post and in the post body as well?

    KeithS

    #35270

    I don’t believe I can post the URL publicly because of some semi-adult content which may not be acceptable.

    As an aside, using this on another site with Graphene (www.rjet.ca – an aviation news site) did not cause the issue, when running the plugin in its original form so I am assuming a plugin conflict and I’m turning plugins off and clearing cache in an attempt to narrow the problem further on the site we are having issues with.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.