Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Breaking up a long Post into different pages from within my theme WordPress

  • SOLVED

I know traditionally you can use the <!--nextpage--> to break stuff up but I may have something specific.

I have a for loop in my template file getting individual steps from custom meta boxes for a how-to. This is all on one post and I would like to have no more than 4 steps per page.

The code:


<?php
$numPosts = get_post_meta($post->ID, 'ecpt_totalnumberofsteps', true);

for ($i = 1; $i <= $numPosts; $i++) { ?>
<div class="individual-step">
<h3 class="step">Step <?php echo $i; ?></h3>
<?php $slug = basename(get_permalink()); ?>
<img src="/templateImages/video-steps/<?php echo($slug); ?>/<?php echo $i; ?>.jpg" />
<p><?php echo get_post_meta($post->ID, 'ecpt_step' . $i, true); ?></p>
</div>

<?php } ?>



I need it similar to the functionality of:
http://www.eyehandy.com/how-to-build-a-cyclorama-photo-studio-with-ashley/
as to where everything else on the page is pretty much the same except the Steps change.
I would like it to automatically render the number of pages needed and I have the WP-PageNavi plug-in installed for use with it.

So say $numPosts returns "11" I need 3 pages, 4 posts on the first two and 3 on the last.

Answers (1)

2011-10-22

Sébastien | French WordpressDesigner answers:

all the content is in one post (and its custom fields).
and you want a pagination managed by wp-pagenavi ?
not a custom pagination ?


if your question is just : "how can i cut the content after three step ?" the response is that :

<?php
$numPosts = get_post_meta($post->ID, 'ecpt_totalnumberofsteps', true);

for ($i = 0; $i <= $numPosts; $i++) { ?>

<div class="individual-step">
<h3 class="step">Step <?php echo $i; ?></h3>
<?php $slug = basename(get_permalink()); ?>
<img src="/templateImages/video-steps/<?php echo($slug); ?>/<?php echo $i; ?>.jpg" />
<p><?php echo get_post_meta($post->ID, 'ecpt_step' . $i, true); ?></p>
</div>

<? if($i % 3 == 0) apply_filters('the_content', "<!--nextpage-->\n" );

<?php } ?>


Kevin Daniels comments:

doesn't matter to me if it's managed by pageNavi or it's custom, I just need it to work because some of the 'how-to's have like 20 steps. The code you send didn't work for me. what is the "the_content" part point to?

The dev site with the code you suggested is here:
http://www.eyehandy.kevindaniels.net/2011/alcohol/how-to-make-jello-shots-with-jaclyn/

It doesn't appear to do anything as all 8 steps are listed.

I want everything on the page to remain the same besides the actual steps. Any further help?


Sébastien | French WordpressDesigner comments:

ok
Could you increase your fee
this task need some time


Sébastien | French WordpressDesigner comments:

Ok the code is ready. I have test, it's perfect. You can see a demo here : [LINK href="http://demo.archiparmentier.com/non-classe/two-steps-by-page"]http://demo.archiparmentier.com/non-classe/two-steps-by-page[/LINK]
My fee is 30$


Sébastien | French WordpressDesigner comments:

the demo : http://demo.archiparmentier.com/non-classe/two-steps-by-page


Sébastien | French WordpressDesigner comments:

have you seen the demo ?