Issue with blog page

Hi there,

I checked the case and actually, the problem is from Child Theme. As soon as I activate the parent Pro theme it is possible to add the Widgets in the main sidebar with no problem:

Please kindly check the customization you have done in the Child Theme to see which set of code is causing this issue.

Thank you for your understanding.

All the code in the child theme has been added from this blog and you advice.Which one can be the problem?

<?php

// =============================================================================
// FUNCTIONS.PHP
// -----------------------------------------------------------------------------
// Overwrite or add your own custom functions to X Pro in this file.
// =============================================================================

// =============================================================================
// TABLE OF CONTENTS
// -----------------------------------------------------------------------------
// 01. Enqueue Parent Stylesheet
// 02. Additional Functions
// =============================================================================

// Enqueue Parent Stylesheet
// =============================================================================

add_filter( ‘x_enqueue_parent_stylesheet’, ‘__return_true’ );

// Additional Functions
// =============================================================================

// =============================================================================
// Shortcode to add breadcrumbs to Header Builder
function my_breadcrumbs( ) {
$breadcrumbs_on = x_get_option( ‘x_breadcrumb_display’ );
if ( $breadcrumbs_on == ‘1’ ) :
$breadcrumbs = x_breadcrumbs();
endif;
return $breadcrumbs;
}
add_shortcode( ‘breadcrumbs’, ‘my_breadcrumbs’);

// =============================================================================
// Funcion para meter imagen destacada al resumen RSS

function mytheme_excerpt_post_thumbnail($content) {
global $post;
if ( has_post_thumbnail($post->ID) ) {
$content = ‘

’ . get_the_post_thumbnail($post->ID, ‘large’) . ‘
’ . $content;
}
return $content;
}
add_filter(‘the_excerpt_rss’, ‘mytheme_excerpt_post_thumbnail’);

// =============================================================================
// Add Facebook SDK code

function add_facebook_pixel_code(){
?>

<?php } add_action( 'x_before_site_begin', 'add_facebook_pixel_code' );

// =============================================================================
// Add Facebook SDK code

function add_facebook_sdk_code(){
?>

<?php } add_action( 'x_before_site_begin', 'add_facebook_sdk_code' );

// =============================================================================
// Add Pushcrew

function add_pushcrew(){
?>

<?php } add_action( 'x_before_site_begin', 'add_pushcrew' );

// =============================================================================
// Add Cookie Consent

function add_cookie_consent(){
?>

<?php } add_action( 'x_before_site_begin', 'add_cookie_consent' );

// =============================================================================
// Add Adsense Mobile Code

function add_adsense_mobile_code(){
?>

<?php } add_action( 'x_before_site_begin', 'add_adsense_mobile_code' );

// =============================================================================
// Add Google Tag Manager Code

function add_google_tag_manager_code(){
?>

<?php if ( function_exists( 'gtm4wp_the_gtm_tag' ) ) { gtm4wp_the_gtm_tag(); } ?>
<?php } add_action( 'x_before_site_begin', 'add_google_tag_manager_code' );

// Author Field below the post content - Single page only.
// =============================================================================

add_filter( ‘the_content’, ‘custom_author_code’);

function custom_author_code($content) {
if ( is_single() ) {
return $content . do_shortcode(’[author title=“Más información sobre el Autor”]’);
} else {
return $content;
}
}

// Author link
// =============================================================================

if ( ! function_exists( ‘x_integrity_entry_meta’ ) ) :
function x_integrity_entry_meta() {

  $author = ' por <a href="'.  get_author_posts_url(get_the_author_meta( 'ID' )) . '">' . get_the_author() . '</a></span>';
$date = sprintf( '<span><time class="entry-date" datetime="%1$s">%2$s</time></span>',
  esc_attr( get_the_date( 'c' ) ),
  esc_html( get_the_date() )
);
if ( get_post_type() == 'x-portfolio' ) {
  if ( has_term( '', 'portfolio-category', NULL ) ) {
    $categories        = get_the_terms( get_the_ID(), 'portfolio-category' );
    $separator         = ', ';
    $categories_output = '';
    foreach ( $categories as $category ) {
      $categories_output .= '<a href="'
                          . get_term_link( $category->slug, 'portfolio-category' )
                          . '" title="'
                          . esc_attr( sprintf( __( "Ver las entradas de: &ldquo;%s&rdquo;", '__x__' ), $category->name ) )
                          . '"> '
                          . $category->name
                          . '</a>'
                          . $separator;
    }
    $categories_list = sprintf( '<span>En %s',
      trim( $categories_output, $separator )
    );
  } else {
    $categories_list = '';
  }
} else {
  $categories        = get_the_category();
  $separator         = ', ';
  $categories_output = '';
  foreach ( $categories as $category ) {
    $categories_output .= '<a href="'
                        . get_category_link( $category->term_id )
                        . '" title="'
                        . esc_attr( sprintf( __( "Ver las entradas de: &ldquo;%s&rdquo;", '__x__' ), $category->name ) )
                        . '"> '
                        . $category->name
                        . '</a>'
                        . $separator;
  }
  $categories_list = sprintf( '<span>En %s',
    trim( $categories_output, $separator )
  );
}
if ( comments_open() ) {
  $title  = get_the_title();
  $link   = get_comments_link();
  $number = get_comments_number();
  if ( $number == 0 ) {
    $comments = sprintf( '<span><a href="%1$s" title="%2$s" class="meta-comments">%3$s</a></span>',
      esc_url( $link ),
      esc_attr( sprintf( __( 'Leave a comment on: &ldquo;%s&rdquo;', '__x__' ), $title ) ),
      __( 'Leave a Comment' , '__x__' )
    );
  } else if ( $number == 1 ) {
    $comments = sprintf( '<span><a href="%1$s" title="%2$s" class="meta-comments">%3$s</a></span>',
      esc_url( $link ),
      esc_attr( sprintf( __( 'Leave a comment on: &ldquo;%s&rdquo;', '__x__' ), $title ) ),
      $number . ' ' . __( 'Comment' , '__x__' )
    );
  } else {
    $comments = sprintf( '<span><a href="%1$s" title="%2$s" class="meta-comments">%3$s</a></span>',
      esc_url( $link ),
      esc_attr( sprintf( __( 'Leave a comment on: &ldquo;%s&rdquo;', '__x__' ), $title ) ),
      $number . ' ' . __( 'Comments' , '__x__' )
    );
  }
} else {
  $comments = '';
}
$post_type           = get_post_type();
$post_type_post      = $post_type == 'post';
$post_type_portfolio = $post_type == 'x-portfolio';
$no_post_meta        = x_get_option( 'x_blog_enable_post_meta' ) == 0;
$no_portfolio_meta   = x_get_option( 'x_portfolio_enable_post_meta' ) == 0;
if ( $post_type_post && $no_post_meta || $post_type_portfolio && $no_portfolio_meta ) {
  return;
} else {
  printf( '<p class="p-meta">%1$s%2$s%3$s%4$s</p>',
    $categories_list,
    $author,
    $date,
    $comments
  );
}

}
endif;

//adjustments to wp-includes/http.php timeout values to workaround slow server responses
add_filter(‘http_request_args’, ‘bal_http_request_args’, 100, 1);
function bal_http_request_args($r) //called on line 237
{
$r[‘timeout’] = 15;
return $r;
}

add_action(‘http_api_curl’, ‘bal_http_api_curl’, 100, 1);
function bal_http_api_curl($handle) //called on line 1315
{
curl_setopt( $handle, CURLOPT_CONNECTTIMEOUT, 15 );
curl_setopt( $handle, CURLOPT_TIMEOUT, 15 );
}

Hi,

You can try removing the last one and check

//adjustments to wp-includes/http.php timeout values to workaround slow server responses
add_filter('http_request_args', 'bal_http_request_args', 100, 1);
function bal_http_request_args($r) //called on line 237
{
$r['timeout'] = 15;
return $r;
}

add_action('http_api_curl', 'bal_http_api_curl', 100, 1);
function bal_http_api_curl($handle) //called on line 1315
{
curl_setopt( $handle, CURLOPT_CONNECTTIMEOUT, 15 );
curl_setopt( $handle, CURLOPT_TIMEOUT, 15 );
}

If that doesn’t help, you can try removing the code bits by bits(by function) and see which one is causing it.

Thanks

The blog sidebar finally works (i just wanted to show posts).

But the shop sidebar still won´t work.

Also, the products show the images weird.

Hi there,

I think you need a permanent solution for that, please add this code to your child theme’s functions.php

  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_home() || x_is_shop() ) {

return 'content-sidebar';

}
    
return $layout;

}

That’s going to permanently apply sidebar to your blog and shop page regardless of your layout setting. Now, just assign the sidebar to your home page and shop page in Admin > Appearance > Sidebars, then add widgets.

As for those product images, they are by design and made like that. How should it look? Perhaps you don’t want the zooming features as well?

Thanks!