Fixpoint

2021-12-27

Header-only archive views in MP-WP

Filed under: MP-WP, Software — Jacob Welsh @ 22:59

This would be one of the simplest, yet most helpful, yet non-obvious changes you can make to a new installation of MP's WordPress, right up there with separating pingbacks from direct comments and chapter-and-verse linking.

By default, queries that return multiple articles just dump them all in full into the same page. That includes for instance the yearly/monthly/daily archives, categories, searches, and possibly front page. The results, once your blog reaches any substantial complexity, include making it darn near impossible to browse for articles by title, pointlessly gigantic pages to load (especially with photo-heavy items in the mix), and amplification of minor formatting gaffes (if you forget to close an html tag in one article, it sometimes ends up applied to everything that follows).

Basically nobody had much of a clue of what a blog even was back then and so they built a twitter feed because who would want to write more than 140 characters at a time anyway, right?(i)

I worked this out just about a year ago; I don't recall how exactly, and nobody asked me until now so I'm reconstructing as best I can (be bothered).(ii) Unfortunately it's one of those "theme-dependent for no conceivable reason" things (TDFNCRs) so this will only apply to the variable-width "classic" theme that I took as the basis for Fixpoint's theme.

--- a/wp-content/themes/classic/index.php
+++ b/wp-content/themes/classic/index.php
@@ -14,9 +14,11 @@
         <h3 class="storytitle"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h3>
        <div class="meta"><?php _e("Filed under:"); ?> <?php the_category(',') ?> &#8212; <?php the_tags(__('Tags: '), ', ', ' &#8212; '); ?> <?php the_author() ?> @ <?php the_time() ?> <?php edit_post_link(__('Edit This')); ?></div>

+<?php if (is_singular()) { ?>
        <div class="storycontent">
                <?php the_content(__('(more...)')); ?>
        </div>
+<?php } ?>

        <div class="feedback">
                <?php wp_link_pages(); ?>

Since the same index.php is used as the entry point for all views in this theme, we add a condition such that the article body is emitted only for single-item pages (search around in wp-includes/query.php for what exactly this means). To prevent pagination you may then also need to raise your "posts_per_page" limit (the entry by that name in the "options" table, or "Settings -> Reading -> Blog pages show at most:" in the GUI); I set mine to 10000. You do not need to touch its companion "posts_per_rss".

For the default theme aka "kubrick" with its greater sprawl of PHP as well as CSS code, there's an entirely different fix that involves finding the right part to cut from archive.php.

  1. I'm expecting this to be among my shortest articles, yet I'm already past the kilobyte mark. [^]
  2. I don't really use version control on my blog code, despite having proposed a few vpatches before. The public MPWP code at least to my eyes remains a huge unmaintained mess that still has to wait its turn behind all the even bigger messes. [^]

2 Comments »

  1. Thanks, applied cleanly to mine.

    Comment by Robinson Dorion — 2021-12-28 @ 15:05

  2. Cool, and I see it indeed had the effect of making the front page basically a full archive listing. Not the worst thing for it to be, especially for young blogs.

    Comment by Jacob Welsh — 2022-01-06 @ 07:33

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by MP-WP. Copyright Jacob Welsh.