PHP Generated product pages e.g: Page: [1] 2 3 4


I have a product page that is generated using WordPress to get the products and display them, however I want to be able to limit the amount visible at one time.

WordPress/PHP generation code:

$pages = get_pages(array('parent' => $post->ID, 'hierarchical' => 0, 'number' => $postsPerPage, 'sort_order' => 'ASC', 'sort_column' => 'menu_order'));
foreach ($pages as $page) {
    $content = '<div class="pcp-product-display">
                    <div class="pcp-left-product-display-container">
                        <h2>' . $page->post_title . '</h2>';
    $content .=         '<div class="pcp-img-container">'. get_the_post_thumbnail($page->ID, 'thumbnail') .'</div>
                    <div class="pcp-right-product-display-container">
                        <div class="pcp-product-excerpt">' . get_field('page_excerpt', $page->ID) . '</div>';
    $content .=         '<div class="price"><p> &pound;' . get_field('product_price', $page->ID) . '</p></div>
                        <div class="pcp-product-display-cta">
                            <a href="' . get_permalink($page->ID) . '"><h3>More Information</h3></a>
                echo $content;

Here is what the page looks like:

I have got the “Items per page” at the top working, but I’d like that to work in conjunction with the pages.

I would like to do this using “product pages”, for example you can see products 1-10 and there are 3 further pages to cycle through. (Page: [1] 2 3 4)

I’m not sure how I would go about getting the “product pages” to work.

Would it be best to use AJAX and grab, say, products 11-20 and then display them?

Or should I use PHP and WordPress?

If you need more information I should be able to provide it.

Read more here: PHP Generated product pages e.g: Page: [1] 2 3 4

Leave a Reply

Your email address will not be published. Required fields are marked *