Portfolio & Category Archive Customization

Hi,

I am using my portfolio for blog posts. I am making some updates and can’t figure out how to do a couple things.

  1. I want to reduce the excerpt length on the index page. I think the excerpts are showing around 50 words now, I’d like to cut that down to 25.

  2. When a user clicks the “Filter Posts” item in the sidebar, it takes them to the Category Archive page. I would like the Category Archive page to display items the same way as the index page (one per row, with the featured image to the left and other information to the right).

  3. I would like to change the title of the Category Archive page. Is this possible? I tried to do it through Posts>Categories>Archive, but it didn’t work.

Information is in secure form. Thank you so much!

Hi there,

Thanks for writing in!

.archive .x-portfolio {
    width: 100% !important;
}
  • You can change the title in each category settings page, just go to Dashboard > Portfolio > Portfolio Categories and edit the category (see screenshot)

Under Archive Title field, change the name (see screenshot)

Cheers!

Amazing! Thank you so much!

One more question: Is it possible to add the sidebar that I have on the portfolio index page to the Category Archive and Search Results pages?

Thanks again!

Hello There,

The only to display the sidebar of the portfolio index in your category archive and search results page is to use this custom code in your child theme’s functions.php file

// Use Portfolio sidebar in category archives and search results
// =============================================================================
add_filter( 'ups_sidebar', 'my_x_custom_sidebar' );
function my_x_custom_sidebar($sidebar){
  if( is_archive() || is_search() ){
    return 'ups-sidebar-home-reviews';
  }
  return $sidebar;
}
// =============================================================================

Please let us know if this works out for you.

Thanks so much. I added the code, to functions.php, but it only worked on the search results page, not the category archive page. Any idea what could be wrong? Thanks!

Hi there,

I see this code in your 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() ) {
        $layout = 'content-sidebar';
      } 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;
  }

Please change it to this, allowing sidebar for archives

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() ) {
        $layout = 'content-sidebar';
      } 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_archive() ) return 'content-sidebar';

    return $layout;
  }

Then test it again.

Thanks!

that worked. Thanks so much!

You’re more than welcome, glad we could help.

Cheers!

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