WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] showing custom data from child pages + pagination (6 posts)

  1. Gavrisimo
    Member
    Posted 4 years ago #

    Hello!

    You can see here what i am doing:

    http://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?

  2. vtxyzzy
    Member
    Posted 4 years ago #

    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.

  3. Gavrisimo
    Member
    Posted 4 years ago #

    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! ;)

  4. vtxyzzy
    Member
    Posted 4 years ago #

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

  5. Gavrisimo
    Member
    Posted 4 years ago #

    Done. ;)

  6. syncbox
    Member
    Posted 4 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags