The code below is leading to a mistake on the site by which you will find ~ 1500 posts. It works fine when publish count is nominal, however, this heavy load is subjecting the weakness from the code and Let me optimize it.

Oddly enough, after i disable this menu and rather make use of the "Recent Posts" widget, the posts are attracted fine. So I'd most likely do good to gain access to from that code basically understood how to locate it, or even better, Basically could call the widget directly during my theme, passing it a publish count variable.

Fatal error: Permitted memory size 33554432 bytes exhausted (attempted to allocate 16384 bytes) in /home1/est/public_html/mysite/wordpress-includes/publish.php online 3462

The code is below. Its purpose would be to list "recent posts".

global $post; 
$cat=get_cat_ID('myMenu'); 
$cathidePost=get_cat_ID('hidePost'); 
$myrecentposts = get_posts(array('post_not_in' => get_option('sticky_posts'), 'cat' => "-$cat,-$cathidePost",'showposts' => $count-of-posts));
$myrecentposts2 = get_posts(array('post_not_in' => get_option('sticky_posts'), 'cat' => "-$cat,-$cathidePost",'showposts' => -1));
$myrecentpostscount = count($myrecentposts2);

if ($myrecentpostscount > 0) 
{ ?>
    <div class="recentPosts"><h4><?php if ($myHeading !=="") { echo $myHeading; } else { echo "Recent Posts";} ?></h4><ul>
    <?php 
    $current_page_recent = get_post( $current_page );
    foreach($myrecentposts as  $idxrecent=>$post) {
        if($post->ID == $current_page_recent->ID)
            {
                $home_menu_recent = ' class="current_page_item';
            } 
            else 
            {
                $home_menu_recent = ' class="page_item';
            }
            $myclassrecent = ($idxrecent == count($myrecentposts) - 1 ? $home_menu_recent.' last"' : $home_menu_recent.'"'); 
        ?>
    <li<?php echo $myclassrecent ?>><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    <?php } ; if (($myrecentpostscount > $count-of-posts) && $count-of-posts > -1){ ?><li><a href="<?php bloginfo('url'); ?>/recent">View All Posts</a></li><?php } ?></ul></div>

Do not take this the wrong manner. I am not likely to solve your memory problem whatsoever within this answer. I'll publish another answer having a reason In my opinion you might have the mem problem This is only a suggestion I think you'll take as useful: You've a lot html jumbled among your layout logic it will get you 3x as lengthy to complete evaluate which is breaking and why.

Following a concepts of refactoring I am likely to give an example and show the best way to clean this up to the stage where one can really debug it yourself.

I am using this portion of code to refactor a little:

if ($myrecentpostscount > 0) 
{ ?>
    <div class="recentPosts"><h4><?php if ($myHeading !=="") { echo $myHeading; } else `{ echo "Recent Posts";} ?></h4><ul>`

First, pull the logic from the template display (reformat for readability simultaneously:

if ($myrecentpostscount > 0)
{
    if ($myHeading !=="") 
    {
        $displayHeading =  $myHeading; 
    } 
    else 
    { 
        $displayHeading =  "Recent Posts";
    }

?>

Second, replace temporary variables with function calls [$myHeading]

/**
* This function determines if a heading is null, and returns the default if it is.
*/
function getDisplayHeading($customHeading)
{
    if ($customHeading == "") 
    { 
        return "Recent Posts";
    }
    return $customHeading;
}   

if ($myrecentpostscount > 0)
{
    ?>
    <div class="recentPosts"><h4>
    <?php echo getDisplayHeading($myHeading); ?></h4><ul>

Now finally, if you have all of your logic towards the top of the page, you are able to profile each function to determine just how much memory it uses and after which an excessive amount of memory can be used inside your page request. I am likely to publish another response to attempt to help there though, because In my opinion I know.