Help with portfolio page side bar

Hello,

I would like to use the Portfolio feature to display the services of my customer who is a dental office.

My issue is that when I add for example;

Dental Cleaning as a portfolio item.

I am not able to add a sidebar to the Portfolio Item.

I am only able to add a sidebar to the Portfolio page.

I viewed other articles and tried but I was not successful at fixing it.

My two questions are;

  1. Do you recommend using Portfolio to act as a services page catalog?
  2. How could I get help to add a sidebar to the Portfolio item?

Thank you in advance.

Hi,

  1. Yes, you can utilize it as your catalog.page

You can check our demo pages to see it in action

  1. By default the portfolio item page is set to full width. To add a sidebar, 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 = 'content-sidebar';
      } 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;
    }
    return $layout;
  }

Hope this helps

Hi, thank you for your reply.

I have done what you said, and it doesn’t work.

I must be doing it wrong.

Hi there,

Did you enable the child theme on the site? If you already did, please provide us with the admin access to your site in a Secure Note:

Hello @lostimagination,

Thanks for providing the information. You are on the right track. To completely resolve your issue which is to display a sidebar in your portfolio item, please do the following:

Since you have your child theme active and ready, please follow these steps below:

  • Using Notepad or TextEdit or Sublime Text or any text editor, please create a new file in your local machine.
  • Insert the following code into that new file
<?php

// =============================================================================
// VIEWS/INTEGRITY/WP-SINGLE-X-PORTFOLIO.PHP
// -----------------------------------------------------------------------------
// Single portfolio post output for Integrity.
// =============================================================================

get_header();

?>

  <div class="x-container max width offset">
    <div class="<?php x_main_content_class(); ?>" role="main">

      <?php while ( have_posts() ) : the_post(); ?>
        <?php x_get_view( 'integrity', 'content', 'portfolio' ); ?>
        <?php x_get_view( 'global', '_comments-template' ); ?>
      <?php endwhile; ?>

    </div>

    <?php if ( $fullwidth != 'on' ) : ?>
      <?php get_sidebar(); ?>
    <?php endif; ?>
    
  </div>

<?php get_footer(); ?>
  • Save the file named as wp-single-x-portfolio.php
  • Upload this file to your server in the child theme’s folder wp-content/themes/x-child/framework/views/integrity/

You will have to create the folder path since it does not exist yet. Please let us know if this works out for you.

It works! Thank you very much!

We are delighted to assist you with this.

Cheers!

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