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

Current Page Number in Collection Storyline? #154

Closed tnog closed 11 years ago

tnog commented 11 years ago

I was wondering if there's a way to show the current page number in a storyline, for example Page 2 of 12?

I know that in paginated posts in WP you can use something like <?php echo '(Page '.$page.' of '.$numpages.')'; ?> to show the above.

I thank anyone in advance if they can lead me to the answer.

mgsisk commented 11 years ago

The short answer is: no… not automatically, at least. WordPres (and Webcomic) don't really have a built-in way to track which is page X of Y within a taxonomy term (though this question comes up enough I probably ought to look into it).

As a slightly-kludgy alternative, you could use a combination of custom fields and get_objects_in_term to simulate this. Assuming your custom field is called page_number, it might look something like:

Page <?php echo get_post_meta( the_ID(), 'page_number', true ); ?> of <?php echo count( get_objects_in_term( get_post_terms( the_ID(), get_webcomic_collection() . '_storyline' ), get_webcomic_collection() . '_storyline' ) ); ?>
tnog commented 11 years ago

Thank you Michael. I figured out an alternative way, not elegant, but each webcomic in the storyline is given a title of Page 1, Page 2, Page 3 which I echo with $title. It won't show you the total pages, but the client just wanted a way to indicate what page the reader was on.

As far as the permalinks go I appended the storyline title for the single webcomic permalinks so that each permalink now reads /comics/mini-comics/%storyline/page-number/.

The only hang-up is that in order to be unique the webcomic slugs, page-1, page-2 etc. are given incremental numbers, i.e.: page-1, page-1-2, page-1-3...

You can see how I've integrated your plugin here: http://sandbox.bravesailor.com/comics

The site is almost ready to go!

cheers,

Tak