0

I am trying to display all the product links (7000+) of woocommerce, but I get a blank result when doing so. When I set 'posts_per_page' to 2000, it returns a result. More than 2000 returns a blank page

<?php if ( is_woocommerce_activated() ): ?>

                <h3><?php _e( 'Product Categories', 'woothemes' ) ?></h3>
                <ul>
                    <?php wp_list_categories( 'taxonomy=product_cat&pad_counts=1&title_li=' ); ?>
                </ul>

                <h3><?php _e( 'Products', 'woothemes' ); ?></h3>
                <ul>
                    <?php
                        $args = array( 'post_type' => 'product','posts_per_page' => -1 );
                        $loop = new WP_Query( $args );
                        while ( $loop->have_posts() ) : $loop->the_post();
                    ?>
                    <li><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></li>
                    <?php endwhile; ?>
                </ul>

                <?php endif; ?>
  • Please enable WP_DEBUG mode and add error messages that come up to your question. – Rarst May 25 '14 at 19:13
  • That's another problem, there is no error even debug is enabled – JPL May 26 '14 at 2:42
1

You are most probably exceeding the maximum execution time when trying to retrieve 7000 posts/products, or specifically more than 2000 posts/products.

To be quite honest with you, 7000 posts/products (or even just a list of posts/products) all packed in one single page is not only going to drive you crazy, but anyone visiting your site. I can imagine how long does 2000 posts/products take to load if just a little more exceeds the maximum execution time, 7000 is more than 3 times more.

If I was a new prospective client, you would have lost my business simply by just frustrating me when a extremely long page load.

  • 1
    any alternative solution, how about creating a pagination for the 7000+ line e.g. each pagination will have 1000 products though i think that would beat the purpose of a sitemap – JPL May 26 '14 at 2:46
  • I've been thinking about an alternative, but can't seem to come up with one. – Pieter Goosen May 26 '14 at 4:23
  • thanks really appreciate maybe i should just create a php code calling all the links for loop and use iframe just not sure how to do that – JPL May 27 '14 at 7:03
  • Have you tried wp_get_archives('type=alpha'); – Pieter Goosen May 27 '14 at 16:32
  • yes i did alreadu – JPL Jun 15 '14 at 12:41

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.