Whoops \ Exception \ ErrorException (E_WARNING)
Invalid argument supplied for foreach() Whoops\Exception\ErrorException thrown with message "Invalid argument supplied for foreach()" Stacktrace: #4 Whoops\Exception\ErrorException in /home/coresa/public_html/wp-content/themes/darwin_evo/single.php:43 #3 Gantry\Component\Whoops\SystemFacade:handleError in /home/coresa/public_html/wp-content/themes/darwin_evo/single.php:43 #2 include in /home/coresa/public_html/wp-includes/template-loader.php:98 #1 require_once in /home/coresa/public_html/wp-blog-header.php:19 #0 require in /home/coresa/public_html/index.php:17
Stack frames (5)
4
Whoops\Exception\ErrorException
/home/coresa/public_html/wp-content/themes/darwin_evo/single.php43
3
Gantry\Component\Whoops\SystemFacade handleError
/home/coresa/public_html/wp-content/themes/darwin_evo/single.php43
2
include
/home/coresa/public_html/wp-includes/template-loader.php98
1
require_once
/home/coresa/public_html/wp-blog-header.php19
0
require
/home/coresa/public_html/index.php17
$context['page_head'] = $theme->render('partials/page_head.html.twig', $context);
 
$post = Timber::query_post();
$templates = ['single-' . $post->ID . '.html.twig', 'single-' . $post->post_type . '.html.twig', 'single.html.twig'];
 
$categoriesPost = get_the_category($post->id);
$categories = [];
 
foreach ($categoriesPost as $category):
    $categories[] = $category->term_id;
    if($category->category_parent!=0):
        $categories[] = $category->category_parent;
    endif;
endforeach;
 
$context['wp_title'] .= ' - ' . $post->title();
 if(in_array(2,$categories) || in_array(15,$categories)):
 
     $related_project_ids = get_field('project',$post->ID);
     foreach($related_project_ids as $related_project_id):
         $related_project = get_permalink($related_project_id);
     endforeach;
     
     $post->related_project_urls = $related_project;
    array_unshift($templates, 'single-news.html.twig');
    
elseif(in_array(3,$categories) || in_array(17,$categories)):
    $post->gallery = get_field('gallery',$post->ID);
    
    // foreach($post->galleryTemp as $galleryItem):
    //     $galleryItemTemp = $galleryItem;
    //     if($galleryItem->width > $galleryItem->height):
    //          $galleryItemTemp->class='  ';
    //     else:
    //          $galleryItemTemp->class=' style="object-fit: contain !important;" ';
    //     endif;
    //     $gallery[] =$galleryItemTemp;
    // endforeach;
    // // if(get_current_user_id()==1):
    // //     echo json_encode($gallery);
$context['page_head'] = $theme->render('partials/page_head.html.twig', $context);
 
$post = Timber::query_post();
$templates = ['single-' . $post->ID . '.html.twig', 'single-' . $post->post_type . '.html.twig', 'single.html.twig'];
 
$categoriesPost = get_the_category($post->id);
$categories = [];
 
foreach ($categoriesPost as $category):
    $categories[] = $category->term_id;
    if($category->category_parent!=0):
        $categories[] = $category->category_parent;
    endif;
endforeach;
 
$context['wp_title'] .= ' - ' . $post->title();
 if(in_array(2,$categories) || in_array(15,$categories)):
 
     $related_project_ids = get_field('project',$post->ID);
     foreach($related_project_ids as $related_project_id):
         $related_project = get_permalink($related_project_id);
     endforeach;
     
     $post->related_project_urls = $related_project;
    array_unshift($templates, 'single-news.html.twig');
    
elseif(in_array(3,$categories) || in_array(17,$categories)):
    $post->gallery = get_field('gallery',$post->ID);
    
    // foreach($post->galleryTemp as $galleryItem):
    //     $galleryItemTemp = $galleryItem;
    //     if($galleryItem->width > $galleryItem->height):
    //          $galleryItemTemp->class='  ';
    //     else:
    //          $galleryItemTemp->class=' style="object-fit: contain !important;" ';
    //     endif;
    //     $gallery[] =$galleryItemTemp;
    // endforeach;
    // // if(get_current_user_id()==1):
    // //     echo json_encode($gallery);
            }
 
            break;
        }
    }
 
    if ( ! $template ) {
        $template = get_index_template();
    }
 
    /**
     * Filters the path of the current template before including it.
     *
     * @since 3.0.0
     *
     * @param string $template The path of the template to include.
     */
    $template = apply_filters( 'template_include', $template );
    if ( $template ) {
        include( $template );
    } elseif ( current_user_can( 'switch_themes' ) ) {
        $theme = wp_get_theme();
        if ( $theme->errors() ) {
            wp_die( $theme->errors() );
        }
    }
    return;
}
 
<?php
/**
 * Loads the WordPress environment and template.
 *
 * @package WordPress
 */
 
if ( ! isset( $wp_did_header ) ) {
 
    $wp_did_header = true;
 
    // Load the WordPress library.
    require_once( dirname( __FILE__ ) . '/wp-load.php' );
 
    // Set up the WordPress query.
    wp();
 
    // Load the theme template.
    require_once( ABSPATH . WPINC . '/template-loader.php' );
 
}
 
<?php
/**
 * Front to the WordPress application. This file doesn't do anything, but loads
 * wp-blog-header.php which does and tells WordPress to load the theme.
 *
 * @package WordPress
 */
 
/**
 * Tells WordPress to load the WordPress theme and output it.
 *
 * @var bool
 */
define( 'WP_USE_THEMES', true );
 
/** Loads the WordPress Environment and Template */
require( dirname( __FILE__ ) . '/wp-blog-header.php' );
 

Environment & details:

empty
empty
empty
Key Value
wp-wpml_current_language en
empty
Key Value
SERVER_SOFTWARE Apache
REQUEST_URI /news/admiral-agioi-anargiroi/
PATH /usr/local/bin:/usr/bin:/bin
TEMP /tmp
TMP /tmp
TMPDIR /tmp
PWD /
HTTP_ACCEPT text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
HTTP_ACCEPT_ENCODING br,gzip
HTTP_ACCEPT_LANGUAGE en-US,en;q=0.5
HTTP_CONNECTION Keep-Alive
CONTENT_LENGTH 0
HTTP_HOST core-sa.com
HTTP_USER_AGENT CCBot/2.0 (https://commoncrawl.org/faq/)
HTTP_X_HTTPS 1
REDIRECT_UNIQUE_ID Xo8xRtRMEJFqW5WuTVfpCgAAAQw
REDIRECT_SCRIPT_URL /news/admiral-agioi-anargiroi/
REDIRECT_SCRIPT_URI https://core-sa.com/news/admiral-agioi-anargiroi/
REDIRECT_HTTPS on
REDIRECT_SSL_TLS_SNI core-sa.com
REDIRECT_STATUS 200
UNIQUE_ID Xo8xRtRMEJFqW5WuTVfpCgAAAQw
SCRIPT_URL /news/admiral-agioi-anargiroi/
SCRIPT_URI https://core-sa.com/news/admiral-agioi-anargiroi/
HTTPS on
SSL_TLS_SNI core-sa.com
SERVER_SIGNATURE
SERVER_NAME core-sa.com
SERVER_ADDR 85.93.91.139
SERVER_PORT 443
REMOTE_ADDR 3.83.188.254
DOCUMENT_ROOT /home/coresa/public_html
REQUEST_SCHEME https
CONTEXT_PREFIX
CONTEXT_DOCUMENT_ROOT /home/coresa/public_html
SERVER_ADMIN webmaster@core-sa.com
SCRIPT_FILENAME /home/coresa/public_html/index.php
REMOTE_PORT 49342
REDIRECT_URL /news/admiral-agioi-anargiroi/
SERVER_PROTOCOL HTTP/1.1
REQUEST_METHOD GET
QUERY_STRING
SCRIPT_NAME /index.php
PHP_SELF /index.php
REQUEST_TIME_FLOAT 1586442566.1574
REQUEST_TIME 1586442566
Key Value
PATH /usr/local/bin:/usr/bin:/bin
TEMP /tmp
TMP /tmp
TMPDIR /tmp
PWD /
0. Whoops\Handler\PrettyPageHandler