1

I'm attempting to incorporate an incremental counter inside an array function, that is, in turn, inside the post's while loop. However, I am only able to get it to count to 1.

This is what I currently have:

if ( have_posts() ) :
    while ( have_posts() ) : the_post();
        for ( $i = 1; $i <= 1; $i++ ) {
            webcomic_storylines_list( [
                'link'            => '<div class="media">{{%large}}</div>',
                'order'           => 'desc',
                'depth'           => 1,
                'webcomics_depth' => 0,
                'webcomics'       => [
                    'format' => '<div class="wrapper collapsed"><div class="overlay"></div>{{}}</div>',
                    'link'   => $i,
                    'order'  => 'asc'
                ]
            ] );
        }
    endwhile;
endif;

I've also tried placing the while loop inside the for loop, with no success.

The plugin used is Webcomic by Michael Sisk.

Any help would be much appreciated.

EDIT:

Apologies for the initial vagueness of my question.

What I would like to do is output webcomic posts (a custom post type created by the Webcomic plugin) with the following display in an archive:

Comic Pages:

1 ~ 2 ~ 3 ~ 4 ~ -5 ~ 6

etc., etc.

Each number relates to the page number of published webcomics and simply increases by 1 each time a webcomic is published. So the first webcomic post published would be page 1.

Essentially, what I am trying to create is a custom post type archive that is just a list of the page numbers and the page number is a link into the post itself.

The above code utilises a custom template tag created by the Webcomic plugin and is used in place of a template partic. The function and array are drawing from a custom taxonomy (again created by the plugin), which is basically categorisation of the webcomic pages. It is the 'link' inside 'webcomics' that outputs the post itself.

If one imagines a normal blog index might look like the below, I'd like to make this 'comic' index/archive look like what's on the right. Everything like chapter headings and the like are handled by the plugin -- it's just the page count I'm trying to implement.

+--------------------------+---------+    +-------------------------+---------+
|                          |         |    |                         |         |
|        Blog Index        |         |    |       Comic Index       |         |
|                          |         |    |                         |         |
| +---+  Title             |         |    |   Chapter 1             |         |
| |   |                    |         |    |                         |         |
| +---+  Excerpt...        | Sidebar |    |    1 ~ 2 ~ 3 ~ 4 ~ 5    | Sidebar |
|                          |         |    |    6 ~ 7 ~ 8 ~ 9 ~ 10   |         |
| +---+  Title             |         |    |                         |         |
| |   |                    |         |    |   Chapter 2             |         |
| +---+  Excerpt...        |         |    |                         |         |
|                          |         |    |    1 ~ 2 ~ 3 ~ 4 ~ 5    |         |
| +---+  Title             |         |    |    6 ~ 7 ~ 8 ~ 9 ~ 10   |         |
| |   |                    |         |    |                         |         |
| +---+  Excerpt...        |         |    |   Chapter 3             |         |
+--------------------------+---------+    +-------------------------+---------+

Finally, to be clear, the plugin does have the ability the output the post's title with %title in place of where $i currently is -- however, this would mean I'm unable to name the post/webcomic page anything other than a string of numerals.

The CPT is webcomic. Inside that CPT, there are a couple of custom taxonomies: webcomic_storyline is one of them and this is what dictates a 'chapter'. It is simply categorisation as we find with regular blog posts. A post is a webcomic 'page' and the storyline tax is a webcomic 'chapter'. So the function in my code is listing every 'chapter' (category) and then drawing every 'page' (post) that corresponds to that 'chapter'.

| improve this question | | | | |
  • So for every post (while) you want webcomic_storylines_list() called 99 times (first with 'link' => 1 then 'link' => 2 until 'link' => 99), do I understand this correct? – kero Aug 22 '18 at 11:23
  • 2
    why are you incrementing counter again in link property? Simply put $i. – Jitender Singh Aug 22 '18 at 11:52
  • @kero Oops. Looks like I've missed that '99' when I copied my code across... I increased the number to 99 to check the counter (which, as expected, calls webcomic_storylines_list() and incrementally increases). I have edited my post accordingly and it is now back to '1'. @JitenderSingh You're right -- $i++ is unneeded. Have edited my code to reflect this. – Ash Aug 23 '18 at 1:55
  • 1
    @Ash I still don't have any idea what you're trying to achieve. Can you elaborate more in the question? – kero Aug 23 '18 at 10:12
  • 1
    @Ash Ok, I think I got it. Sadly, I have to leave right now. I will take a look at this in an hour or so. Meanwhile I will try to reach a mod to reopen your question, as it is much clearer now what you want to achieve – kero Aug 24 '18 at 10:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.