WordPress Archive Links not working

Was put on a project to fix the archive links on a WordPress site. It’s someone else’s code and is quite messy.

Problem: Archive widget displays fine in the side bar, but links themselves do not work. Clicking link (e.g. www.site.com/2015/03/) does not sort posts, page loads but only with most recent posts (url changes though).

Read More

My Attempts:

  1. deleted .htaccess file
  2. Saved permalinks again in settings
  3. turned off all plugins
  4. replaced all WP core files
  5. changed themes – NOTE: Works with TwentyFifteen Theme

Based on what I’ve tried, the only thing that worked was changing themes. This isn’t an option though. What can I do to help sift through the code, are there any tips for troubleshooting?

Thanks for the help!

Edits
There is no archive.php page. There is a custom blog.php page, here is the loop it’s using.

 <?php 
                $temp = $wp_query; $wp_query= null;
    $wp_query = new WP_Query(); $wp_query->query('cat=' . get_cat_ID("Blog") . '&showposts=5' . '&paged='.$paged);
    while ($wp_query->have_posts()) : $wp_query->the_post();
                    ?>
                    <div id="post-<?php echo get_the_ID(); ?>" <?php echo post_class(); ?>>
                        <div class="eachPost">
                                <div class="postTitle"><a href="<?php the_permalink(); ?>" title="Title"><?php the_title(); ?></a></div>
                           <div class="postMeta">
                               by <?php the_author(); ?> on <?php the_time('F jS, Y'); ?>
                           </div>
                           <div class="entry">
                           <?php 
global $more;    // Declare global $more (before the loop).
$more = 0;       // Set (inside the loop) to display content above the more tag.
the_content('Read the rest of this entry ➞');
?>


                            </div><!-- entry -->
                        </div><!-- eachPost -->
                        <div class="postMetaComments">
                            <div class="postComments">
                                <?php comments_popup_link('No Comments ', '1 Comment ', '% Comments '); ?>
                            </div>
                            <div class="clear-both"></div>
                        </div>  <!-- postMetaComments -->
                    </div><!-- /#post-<?php echo get_the_ID(); ?> -->
    <?php endwhile; ?>

Related posts

Leave a Reply

1 comment

  1. The following might be considered a first step in troubleshooting. You mentioned there is no archive.php file. If there is also no date.php file, copy the code you pasted in your question into a new file, within the theme folder, called date.php. Replace everything in the first <?php ?> tag with this:

    while (have_posts()) : the_post();
    

    From the comments in your question I assume you know to include the snippets before and after the loop again also. E.g.

    get_header();
    
    // Loop goes here
    
    get_footer();
    

    I once had a SEO plugin installed and checked the ‘disable date-based archives’. I doubt this would be the problem in your scenario, seeing as changing to TwentyFifteen theme corrects the problem.