Setting Portfolio entry-top-navigation to Different URLs

I have two different pages displaying portfolio items. Each displays portfolio items of a different Portfolio Category. One displays the “Adventure” Portfolio Category. The other displays the “Profile” Portfolio Category. For flexibility of page layout, neither one of these pages uses the default Portfolio Layout Template. Therefore, when an individual portfolio item of the different types is displayed, I’d like to set the entry-top-navigation (nine black squares icon anchor) to the appropriate parent page.

I’ve place the following framework\functions\ethos.php function within my child-theme functions.php file:

// Entry Top Navigation
// =============================================================================

if ( ! function_exists( 'x_ethos_entry_top_navigation' ) ) :
  function x_ethos_entry_top_navigation() {

    if ( x_is_portfolio_item() ) {
      $link = x_get_parent_portfolio_link();
    } elseif ( x_is_product() ) {
      $link = x_get_shop_link();
    }

    $title = esc_attr( __( 'See All Posts', '__x__' ) );

    ?>

      <div class="entry-top-navigation">
        <a href="<?php echo $link; ?>" class="entry-parent" title="<?php $title; ?>"><i class="x-icon-th" data-x-icon="&#xf00a;"></i></a>
        <?php x_entry_navigation(); ?>
      </div>

    <?php

  }
endif;

I’d like to update the $link value based on the current portfolio’s category. I’m trying something like the following:

if ( x_is_portfolio_item() ) { 
  /* CC——————————————-------------------------------- */
        if (in_category(‘Adventure’)) {
            $link = ‘http://courageouscaterpillar.com/adventures/‘;}
        elseif (in_category(‘Profile’)) {
            $link = ‘http://courageouscaterpillar.com/profiles/‘;}
        else {
            $link = x_get_parent_portfolio_link();}
   /*  CC———————————————————------———— */
} elseif ( x_is_product() ) {
  $link = x_get_shop_link();
}

I don’t believe I’m setting the STRING $link values or identifying the portfolio categories correctly. Any point in the right direction would be greatly appreciated.

Thanks!

Hi there,

The last part of the code which the in_category function used seems to be the problem in my opinion. The portfolio is a custom post type and to retrieve the category of the custom post type you need to use the terms and taxonomies.

I suggest that you read this article for more information:

For further reading, I suggest you follow this google search.

If you want to get the information of the portfolio and how it is added as a custom post type kindly read this file:

wp-content/themes/x/framework/functions/global/admin/custom-post-types.php

Thank you.

Hello Everyone,

Is there a way to change the link on all the portfolio pages (the link from the 9 square icon) to another page? I used ‘The Grid’ to make a better portfolio page (I called the page ‘Case Studies’, https://www.consultparv.com/case-studies/) but when I click on individual cases, there is a 9 square icon that links to the old/incorrect portfolio page.

Thanks for your help.

Hi There,

Please add this custom JS under Customizer > Custom > Global Javascript:

jQuery(".single-x-portfolio a.entry-parent").attr("href", "https://www.consultparv.com/case-studies/");

Let us know how it goes!

1 Like

Worked perfectly, thanks a lot guys :smile:

You are most welcome. :slight_smile:

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