• Resolved lizmcreations

    (@lizmcreations)


    This is the full error message:

    Warning: in_array() expects parameter 2 to be array, null given in /home/mjrphoto/public_html/wp-includes/post-template.php on line 1059

    I have narrowed it down to an issue between the theme and e-commerce plugin.

    I am using Envisioned theme by Elegant Themes and Marketpress shopping cart.

    The plugin support says to talk to the Theme support and the theme support says to talk to the plugin support.

    the error only shows up on the product pages —

    this is the code in post-template.php

    1057 if ( !empty($current_page) ) {
     1058			$_current_page = get_post( $current_page );
     1059			if ( in_array( $page->ID, $_current_page->ancestors ) )
     1060				$css_class[] = 'current_page_ancestor';
     1061			if ( $page->ID == $current_page )
     1062				$css_class[] = 'current_page_item';
     1063			elseif ( $_current_page && $page->ID == $_current_page->post_parent )
     1064				$css_class[] = 'current_page_parent';
     1065		} elseif ( $page->ID == get_option('page_for_posts') ) {
     1066			$css_class[] = 'current_page_parent';
     1067		}

    this is a link to one of the pages with the error on it:
    https://mjrphotographyct.com/store/products/category/simsbury-basketball/

    does anyone have any thoughts or suggestions on what I need to do to fix this?

    Thank you!!

Viewing 2 replies - 1 through 2 (of 2 total)
  • you can change

    if ( in_array( $page->ID, $_current_page->ancestors ) )

    to

    if (is_array($_current_page->ancestors) && in_array( $page->ID, $_current_page->ancestors ) )

    which will make sure $_current_page->ancestors is an array before trying to use the array.. but this patch will only work until you update wordpress as this file could get over written.

    Thread Starter lizmcreations

    (@lizmcreations)

    That worked perfectly – thank you!!

    I’m not so much concerned with it being a “patch” because the issue only started happening recently – so I’m hoping that by the time there is an update there won’t be a conflict anymore — and if there is, I’ll just re-do the patch :).

    Liz

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘error on site – Warning: in_array() expects parameter 2 to be array, null given’ is closed to new replies.