Sidebar not working - PHP error

Hi there,

I have changed the page template to layout - content left, sidebar right. And also tried “appearance > sidebar >” to make a custom sidebar into different pages. I got this error:
[20-Oct-2017 04:09:54 UTC] PHP Warning: array_key_exists() expects parameter 2 to be array, boolean given in /home/cruxdevc/www.tkado.com.au/wp-content/themes/x/framework/functions/global/admin/sidebars.php on line 378

Then I tried the portfolio layout to just check if it would word - then i got these errors:
[20-Oct-2017 10:21:11 UTC] PHP Warning: in_array() expects parameter 2 to be array, string given in /home/cruxdevc/www.tkado.com.au/wp-content/themes/x/framework/functions/global/portfolio.php on line 112
[20-Oct-2017 10:21:11 UTC] PHP Warning: Invalid argument supplied for foreach() in /home/cruxdevc/www.tkado.com.au/wp-content/themes/x/framework/functions/global/portfolio.php on line 128
[20-Oct-2017 10:21:11 UTC] PHP Warning: in_array() expects parameter 2 to be array, string given in /home/cruxdevc/www.tkado.com.au/wp-content/themes/x/framework/views/global/_portfolio.php on line 39

This theme is not working for me

Hi @christian_y,

These are the issues (in this post) that I am having:

another php error:
[21-Oct-2017 03:47:15 UTC] PHP Warning: in_array() expects parameter 2 to be array, string given in /home/cruxdevc/www.tkado.com.au/wp-content/themes/x/framework/functions/global/portfolio.php on line 116

I have updated the theme to version 5.2.2 hoping these issues to be resolved but it didn’t.

Hi,

Please update Cornerstone to latest version(v2.1.3) as well.

Then check every plugin and make sure they have the following version numbers

Hope that helps.

Hi @paul.r

It did not work. Any time that a template is changed, the page is not updated.

Not sure what else to do -

Hi @Rad

This is the video link:
https://www.youtube.com/watch?v=hQXE3Ra0MZM&feature=youtu.be

thanks

Hi,

Thank you for the video.

By default the page layout will only work if you have not selected Full Width as your Content Layout under Theme Options > Layout and Design

To make it work, you can add the code below in your child theme’s functions.php file.

function x_get_content_layout() {
    $content_layout = x_get_option( 'x_layout_content' );
    if ( $content_layout != 'full-width' ) {
      if ( is_home() ) {
        $opt    = x_get_option( 'x_blog_layout' );
        $layout = ( $opt == 'sidebar' ) ? $content_layout : $opt;
      } elseif ( is_singular( 'post' ) ) {
        $meta   = get_post_meta( get_the_ID(), '_x_post_layout', true );
        $layout = ( $meta == 'on' ) ? 'full-width' : $content_layout;
      } elseif ( x_is_portfolio_item() ) {
        $layout = 'full-width';
      } elseif ( x_is_portfolio() ) {
        $meta   = get_post_meta( get_the_ID(), '_x_portfolio_layout', true );
        $layout = ( $meta == 'sidebar' ) ? $content_layout : $meta;
      } elseif ( is_page_template( 'template-layout-content-sidebar.php' ) ) {
        $layout = 'content-sidebar';
      } elseif ( is_page_template( 'template-layout-sidebar-content.php' ) ) {
        $layout = 'sidebar-content';
      } elseif ( is_page_template( 'template-layout-full-width.php' ) ) {
        $layout = 'full-width';
      } elseif ( is_archive() ) {
        if ( x_is_shop() || x_is_product_category() || x_is_product_tag() ) {
          $opt    = x_get_option( 'x_woocommerce_shop_layout_content' );
          $layout = ( $opt == 'sidebar' ) ? $content_layout : $opt;
        } else {
          $opt    = x_get_option( 'x_archive_layout' );
          $layout = ( $opt == 'sidebar' ) ? $content_layout : $opt;
        }
      } elseif ( x_is_product() ) {
        $layout = 'full-width';
      } elseif ( x_is_bbpress() ) {
        $opt    = x_get_option( 'x_bbpress_layout_content' );
        $layout = ( $opt == 'sidebar' ) ? $content_layout : $opt;
      } elseif ( x_is_buddypress() ) {
        $opt    = x_get_option( 'x_buddypress_layout_content' );
        $layout = ( $opt == 'sidebar' ) ? $content_layout : $opt;
      } elseif ( is_404() ) {
        $layout = 'full-width';
      } else {
        $layout = $content_layout;
      }
    } else {
      $layout = $content_layout;
    }
    
    if ( is_page_template( 'template-layout-content-sidebar.php' ) ) {
        $layout = 'content-sidebar';
    } elseif ( is_page_template( 'template-layout-sidebar-content.php' ) ) {
        $layout = 'sidebar-content';
    } elseif ( is_page_template( 'template-layout-full-width.php' ) ) {
        $layout = 'full-width';
    }
    
    return $layout;
  }

Hope that helps.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.