Tweaking ComicPress: More Ado About Multiple Comics

Note: This tutorial refers to a Comicpress site that’s no longer in use. I’ve moved on to Comic Easel now and, to be honest, so should you. Just in case you’re wondering why ths doesn’t seem to apply to what I did on this site. You’re right. Also, this tweak works with Comicpress 2.9.2.29 and below. No guarantees above that. In fact, I’m pretty sure it was already outdated with 2.9.2.30.

My previous post about tweaking ComicPress into working as a multi-comics site got quite a bit of attention. ComicPress’ Frumph even linked to it in the tutorial section of Comicpress.net. Which, in my book, makes it a matter of responsibility to keep you folks up to date about the changes I’ve made to my fix since then, particularly to part 4 of the tutorial – creating custom home pages for the comics.

The templates I’ve created before work just fine for displaying the current comic within a page layout, but they depend on how your WordPress treats pages, making it hard to customize them beyond what’s possible in a WP page. That’s due to WordPress’ architecture – pages and posts work differently.

For example, I’ve customized CP to use a different layout setting for ‘landscape’ formats like this one. This didn’t work on the custom pages.

Please remember this isn’t an official ComicPress extension or anything fancy. It’s just a rag-tag fix I made for myself to solve a problem on my site. I’m sure there are more elegant ways to do this – actually, one is even described as an alternative somewhere below. I try stuff until it works, and then I leave it that way. Use at your own risk, and feel free to improve my fix and tell us all about it in the comments or in your own blog.

1. The Page Template

In theory, you don’t need an extra page template for this, but for some reason it works better on my site, so here goes.

Create a page template called comicindex.php and upload it to the theme’s folder via ftp. (If you’re using a child theme, upload it there.) If you’ve still got the templates from the other tutorial, trash them all except for one and modify that one.

The template should read like this:

<?php
/*
Template Name: Comicindex
*/
get_header();
get_footer();
?>

Yes, that’s true, there’s basically nothing in it. The point is, it clearly states that there’s nothing in it. I still don’t know why, but it does make a difference. On my site, anyway. If you can get away with it, skip this step and choose the “default” template in the next step.

2. The Page

Next, you need a page to be your comic’s home page. (If you’ve already created home pages the last time I wrote about this, edit those.) All you need is an empty page. Choose “Comicindex” as your template. (Or default, see above.)

3. The Layout Header

Open ComicPress’ layout-head.php in a text editor on your computer (do not do this in WP’s online editor!).
Look for this code:

if (!is_paged()) {
if (is_home()) {
if (!comicpress_themeinfo('disable_comic_frontpage')) {
$wp_query->in_the_loop = true; $comicFrontpage = new WP_Query(); $comicFrontpage->query('showposts=1&cat='.comicpress_all_comic_categories_string());
while ($comicFrontpage->have_posts()) : $comicFrontpage->the_post();
comicpress_display_comic_area();
endwhile;
}
} else {
if (is_single() && comicpress_in_comic_category()) {
comicpress_display_comic_area();
}
}
}

Replace the “.comicpress_all_comic_categories_string()” bit with the category number or an array of the category numbers you want to show. Also, get rid of the conditional tags. They’re for sorting out what page you’re on, but this code is for just one specific page. Here’s the bit to keep:

$wp_query->in_the_loop = true; $comicFrontpage = new WP_Query(); $comicFrontpage->query('showposts=1&cat=45');
while ($comicFrontpage->have_posts()) : $comicFrontpage->the_post();
comicpress_display_comic_area();
endwhile;

Assuming your comic, which, btw, I’m going to call ‘Funnybits’ for now, has the category number 45.

There’s a similar bit further down the file which defines the blog post to go with the comic. Treat it the same way if you want the post on the page. Otherwise, trash it.

Then save the file as layout-head45.php or layout-headfunnybits.php. Do not save it as layout-head.

Repeat for your other comics, “Seriousbits” and “Furrybits”. Upload the files to your (child) theme via ftp.

(Alternately, you can include the modified code for each of your comics within conditional tags in your original layout-head, but that could make your layout-head clumsier, messier and slower. I gotta admit, though, I haven’t tried the alternative, so I’m just guessing that would happen.)

4. The Header

Open header.php. (Yes, you can do this in the WP editor again.)
Look for this line:
get_template_part('layout', 'head');

It should be right at the end. Change it to:

if (is_page('funnybits')) {
get_template_part('layout', 'headfunnybits'); } elseif
(is_page('furrybits')) {
get_template_part('layout', 'headfurrybits'); } elseif
(is_page('seriousbits')) {
get_template_part('layout', 'headseriousbits'); } else
get_template_part('layout', 'head');

Assuming, of course, your pages are called ‘funnybits’, ‘furrybits’ and ‘seriousbits’.

So, what’s the difference?

The other script was more of a simulation of a comic display. It took the comic’s files from The Loop and mirrored them within the editable area of the page. This new script uses the same code as the front page, except that it only reads the comics from the series you defined in each file. The display won’t be constrained by the page architecture, and you can edit your pages more freely, like I did with the landscape pages.

Huh, I might add a tutorial for that, too. Maybe later.


14 thoughts on “Tweaking ComicPress: More Ado About Multiple Comics

    • It’ll look any way you layout your page. By default, it’ll probably look like your index page, but with just the comics from one series. You can then customize the pages to show different links and all that, but that’s your call.

  1. I know you said to ignore this comment, but in case somebody else wonders:
    It worked with every WordPress version so far, but not with every comicPress version. (Up to 2.9.something.)

  2. Hi there!

    I’ve opened the layout-theme.php but the text you inform to look for is not there…is this something I should just add in?

    Also, I’m new to this whole WP/CP thing and I’m not sure what you mean when you say to make the category a number like “45”

    Thanks,

    -Phil

    • You’re probably using the current ComicPress, being new to it and all? Because, as I’m saying in the text and should probably highlight or something, this piece of code was in 2.9.2.29, but it’s NOT in 2.9.2.30 or whatever the current version is. It’s in a different file altogether, and its implementation is different, too, I think. But Comicpress’ Frumph assured me that the new Comicpress actually has some functionality that can be used for multiple comics. Just ask in the CP forum.

      As for the category number, just use whatever categpory numbers your comics have. You find out what they are if you hover your mouse over the ‘edit’ links in the Categories menu.

      • Actually, due to some complexities with the new stuff (from what I interpreted on-line) I chose to download 2.8…hoping it would simplify things.

        I’m finding that it’s helping me get a bit farther but it is still not without its challenges. Does this change things? Should I go to the new version and start over?

  3. I’ve been making progress but there were a couple things I was unsure about.

    1) How do I remove the title off the page without causing some sort of error (I’m referring to ‘Who’s Who’) so that the only indicator is the highlighted menu bar?

    2) How can I remove the calendar and alter-menu on the right hand side of the page?

    Thanks!

    • Sorry for taking so long. I don’t really know what you mean by 1), but I think you should be able to edit that out in header.php or layout-head.php. I suggest try and error. 2) The default thingies in the right bar disappear once you put something into the right sidebar in “widgets”. If you don’t want anything there, there are some lines in sidebar-right.php referring to these. Some conditional tag (“if()” that defines what happens when there’s nothing in the sidebar. I can’t seem to find an unmodified version right no, so again, just try stuff. Keep backups, though.

  4. Hi Max!

    I just officially launched my website retailsunshine.com
    and things ended up working out pretty well. There are still a bunch of things I’ve yet to learn in order to create more variety on my site but for now it is functioning and doesn’t burn the retinas like it could.

    There is one burning question I have however in regards to the “First” & “Previous” buttons underneath my comics: How can I enlarge that text, or move it closer to the comic OR remove it altogether in exchange for a better navigation system?

    The one thing I noticed was that it has something to do with the “displaycomicpost.php” section…however I’m not comfortable editing that thing at my current state of knowledge. Thanks for all your help!

    • Congrats on getting that launch done, Phil! As for your question: You can edit the looks of those links in the css file. The class seems to be “nav”. You can make the font bigger (font-size) or the top margin of the text smaller (margin-top) to get it closer to the comics area. To get it closer to the actual comic, I suggest reducing the white space in the comics area, either by css or by removing the title from the posts (in CP manager, if I recall corectly) and moving the bookmark gadget to the sidebar.

  5. Great walk through! Very helpful. Question, is there a way to have the title and post info display on the page as well? For example on my site, Bean Bag Bukakke only shows the comic and nothing else.
    Thanks

    • There are sidebar widgets for that. Just drag one into the “above comic” sidebar, and you should be fine. Or you could do sommething fancier with php elements like “the_title()” or whatever it’s called.
      Oh, and thanks.

Leave a Reply

Your email address will not be published. Required fields are marked *