mgsisk / webcomic

Comic publishing power for the web. Turn your WordPress-powered site into a comic publishing platform with Webcomic.
http://wordpress.org/plugins/webcomic
GNU General Public License v2.0
110 stars 29 forks source link

Custom Theme: Cannot display webcomic on front/home page #230

Closed ashikai closed 9 years ago

ashikai commented 9 years ago

I really do like this plugin but there's one thing that's driving me absolutely crazy. Here's what's up:

I'm trying to create a blank-slate template that I can use for several comics (all owned by different people, so they're separate installs). You can see it here: http://www.shamrockcomic.com (my playground, if you will)

I've got the bulk of the functionality I want down (sans styling), but I'm running into serious issues whenever I try to put things on the main/home/front page.

I'm trying to call the_webcomic SOMEWHERE on the front page. I've tried putting the shortcode in the text editor, and a half-dozen tries were made on the page-450.php file (using the page ID number because both home.php and page-home.php would not overwrite page.php in the heirarchy, and I want to style page.php another way).

WP's Reading tab is set to STATIC PAGE > Home (ID:450)

Homepage is set to the only webcomic collection there is. I am NOT using Webcomic's integrate feature.

I've cleared cache both on WP and in my browser and I'm still not getting anything to display on the front page at all. Not even some non-visible HTML.

I'm seriously stumped. Is there something I've missed about the way the webcomic calls work? Are they only ever going to work on 'single.php' or similar? is there a workaround you would suggest for getting the latest comic post to display on the homepage? Maybe by using a get_webcomic_collection or similar? I think I'm totally misunderstanding some of your documentation.

Any help would be appreciated! Thank you!

mgsisk commented 9 years ago

Apologies for the trouble, @ashikai. It looks like you may have figured this out, but – for others – here are a few things you can do to get webcomic posts on a static front page:

  1. If you're using Inkblot, use Inkblot's Webcomic Homepage template.
  2. If you're not using Inkblot and don't want to mess around with code, turn on Integrate. This should add webcomic posts to the site front page, even if it's a static page.
  3. If you're building a custom theme or modifying an existing one, you'll want to create a page template (or page-specific template, as @ashikai did with the page-450.php file) and add a custom loop to it for displaying Webcomic posts. Inkblot's Webcomic Homepage template actually provides a decent example of how this works, but here's the bare-minimum code you would need to add to a template to get it working:
<?php
    $collection = get_webcomic_collection();
    $webcomics = new WP_Query(array(
        'posts_per_page' => 1,
        'post_type' => $collection ? $collection : get_webcomic_collections()
    ));

    if ($webcomics and $webcomics->have_posts()) :
        while ($webcomics->have_posts()) : $webcomics->the_post();
                the_webcomic();
                // anything else you want to display with the webcomic
        endwhile;
    endif;
?>
ashikai commented 9 years ago

Ahaahaa... I actually figured it out maybe a couple hours after posting this. Thanks so much for responding though! This is pretty much what I ended up doing. XD