[resolved] Too many pages? (6 posts)

  1. mikejandreau
    Posted 6 years ago #

    With some help from the forum, yesterday, I successfully imported about 1400 rows of data into my DEV WordPress install (not my live site, thankfully.)

    However, now when I go to try to "Edit" any page, I get either a script timeout, or a memory allocation error.

    I upped both in my php.ini file, but it still seems like I'm running out of memory, and can't get to the pages to edit them anymore.

    In total, there's only about 1450 pages.
    The dev install has 1452 "Posts", which works fine. Does WordPress handle memory differently in regards to posts vs. pages? Seems like I can have a zillion posts without an issue, but 1450 pages causes an issue.

    Anyone offer any advice? Is 1450 pages too many for a shared host? Should I start looking into VPS or Dedicated?

  2. mikejandreau
    Posted 6 years ago #

    I should also note than these 1450 pages have 5 custom fields, each.

    My postmeta table grew to over 20k rows, which I think may be what's causing the issue in part.

    I deleted all those pages, and their corresponding metadata, and everything's working fine now. But I need to find a solution so I can continue to grow the number of pages. We add about 1 page per day, and have been doing that for 3 years now.

  3. mikejandreau
    Posted 6 years ago #

    I think I solved my own problem.

    From my testing, all day, I learned that WordPress definitely handles posts and pages very differently, which is why I was running out of memory.

    The only reason, I realized, that I was using pages was so that I could utilize the custom template functionality of the pages. Then I realized I could do the same with posts, so why would it matter?

    I simple created a new single-$categoryid template, and added the following to my functions.php file for my theme:
    <?php add_filter('single_template', create_function('$t', 'foreach( (array) get_the_category() as $cat ) { if ( file_exists(TEMPLATEPATH . "/single-{$cat->term_id}.php") ) return TEMPLATEPATH . "/single-{$cat->term_id}.php"; } return $t;' )); ?>

    Now any file that's a "single" post file, will pull single-categoryid.php as its template. Voila.

    Now I just hope WordPress can handle the thousands of posts I'm about to throw at it.

  4. asechrest
    Posted 6 years ago #

    Pretty neat solution. Thanks for sharing. May I ask why you use a separate template for all 1450+ pages (now posts)? Just for curiosity's sake, I'm wondering how you utilize that many templates.

  5. mikejandreau
    Posted 6 years ago #

    I probably should have clarified:

    The main "single.php" template is used for all "news stories" that we post.

    Then we've got a second template "single-1344.php" which will be used for cast member pages.

    And a third "single-1302.php" which will be used for movie reviews.

    Because the cast and movie review pages have a lot of custom fields in them that are different from each other, and the default single page, I wanted them to display differently.

    I didn't meant to insinuate that there's 1450 templates being used, just 3 different ones.

  6. asechrest
    Posted 6 years ago #

    Ahhh, I see. I should have caught that, but in my skimming of your post I read single-categoryid.php as single-POSTid.php.

    Obviously, there's a big difference...1400 templates of difference, I guess. :)

Topic Closed

This topic has been closed to new replies.

About this Topic