• Resolved gavra

    (@gavra)


    Hello!

    You can see here what i am doing:

    https://www.arvag.net/otkrijte-svet/leto/

    So its pulling 2 custom fields from child pages, one of them is just url for the image on the left, and the other field is that text showing on the right.

    Now, what i want to do is to add pagination there. The code i have now will just simply show all child pages, but i want to show only 5 child pages, so if user want to see 6th child page he would have to click on link for “Page 2” and so on.

    The code im using to display these child pages is this:

    <?php
    	$pages = get_pages('child_of='.$post->ID.'&sort_column=post_title&sort_order=desc');
    	$count = 0;
    	foreach($pages as $page)
    	{
    		$short_info = get_post_meta($page->ID,'info',true);
    		$image = get_post_meta($page->ID,'slika',true);
    		$count++;
    	?>
    
    		<div class='preview_slika left'><img src="<?php echo $image ?>" alt="<?php echo $page->post_title ?>" /></div>
    		<div class='preview_info right'>
    			<h2><?php echo $page->post_title ?></h2>
    			<p><?php echo $short_info ?></p>
    			<a href="<?php echo get_page_link($page->ID) ?>">Vi?e o >></a>
    		</div>
    		<div class='clear'></div>
    	<?php
    	}
    ?>

    So any idea what to do to get what i need?

Viewing 5 replies - 1 through 5 (of 5 total)
  • I have posted some sample code here. You may need to modify it to fit into the rest of your template.

    The _mam_paginate() function can be pasted into your functions.php, or left at the end of the template.

    Thread Starter gavra

    (@gavra)

    Hey! Thanks a lot for this code!

    I just moved entire _mam_paginate() function to functions.php and i had to change call to _mam_paginate() function in my template from this:

    _mam_paginate(sizeof($pages),$limit,$range);

    to this:

    echo _mam_paginate(sizeof($pages),$limit,$range);

    Thanks again! ??

    Glad it worked. Now, please use the dropdown at top right to mark this topic ‘Resolved’.

    Thread Starter gavra

    (@gavra)

    Done. ??

    Thanks for the direction here… it helped solve my own issues!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘showing custom data from child pages pagination’ is closed to new replies.