Hide Portfolio Navigation Items for Specific Portfolio Items

Is there a simple way to hide the portfolio page navigation items (9 square icon, next/previous chevron icons)? Ideally, I’d like to do this for one portfolio category.

Thanks.

So, I added the following and this works to remove the navigation items on the portfolio pages (back to parent page, next, previous)

.entry-top-navigation {
  display: none;
}

My question now is - can I easily make this specific to a certain type of portfolio category? I have all the portfolio categories of a certain typed linked to a specific parent page. Those portfolio items I’d like to hide the navigation items. Other portfolio items accessed from other parent pages I’d like to show the default navigation items. Possible?

I tried adding this in an individual Portfolio item “Body CSS Class(es)”, but didn’t work.

Hello There,

To make the code work for a specific to a certain type of portfolio category, you can make use something like this:

.portfolio-category-{name} .entry-top-navigation {
    display: none;
}

Just do not forget to change the category {name}.

Please let us know how it goes.

http://www.courageouscaterpillar.com/classes/yami-parea/

The portfolio category is called “profile”. So I added this to my CSS:

.portfolio-category-profile .entry-top-navigation {
  display: none;
}

The navigation items still don’t appear for ALL categories. Thoughts?

Hey there,

I checked the above URL and the portfolio navigation is hidden for that category, since you’ve made it hidden for profile category. Did you clear the browser’s cache? If this doesn’t help then can you please provide the URL of the categories where it’s visible?

Thanks!

1 Like

Yay! Clearing the browser cache worked. Thank you for the reminder and the assistance. I appreciate your help, Nabeel!

David

Glad we could help.

Cheers!

Whoops! Just noticed something. Maybe it’s on my end? I have a page displaying portfolio items in a grid:

http://courageouscaterpillar.com/adventures/

When I select the first one “YOGA RECOVERY FOR RUNNERS” I get the portfolio page with the navigation controls. That’s great - this is the one I want them on.

http://courageouscaterpillar.com/classes/yoga-recovery-for-runners/

The navigation controls work fine unless I select the “<” on this first item to navigate to the previous item. It takes me to a PROFILE portfolio item which is a different category.

http://courageouscaterpillar.com/classes/yami-parea/

It should keep all the items navigated through within the YOGA and LIFTING Portfolio Categories as specified within the filter constraints. Is this something I’m doing? Is there something else I need to do to limit the portfolio categories navigated through.

Thanks,
David

Hi David,

I am getting this :http://courageouscaterpillar.com/classes/yoga-recovery-for-runners/ from portfolio index page. See this: https://screencast-o-matic.com/watch/cb6u182c11

By default, those next and previous navigation works on all portfolio item and not on specific categories only. The function responsible for that is x_entry_navigation() from this file: wp-content\themes\x\framework\functions\global\content.php. Feel free to copy and customize the function on your child theme functions.php file.

This function: https://codex.wordpress.org/Function_Reference/get_adjacent_post is what handles those filter per category.

Hope this helps.

So, I kept the following CSS to block the navigation controls for profile portfolios:

.portfolio-category-profile .entry-top-navigation {
display: none;
}

Now trying to update the function.php in my child theme to filter out any adjacent posts that are not in the same portfolio category when using other portfolio categories (like: Yoga, Lifting). The “next” control is working fine. It’s just the previous needs adjusting as mentioned above. So I tried customizing the x_entry_navigation() function by adding the second line as shown below.

 $prev_post = get_adjacent_post( false, '', false );  
 $prev_post  = apply_filters( "get_{$adjacent}_post_join", $prev_post, $in_same_cat, ‘’ );

There’s no change though. The previous icon still appears on this page:
http://courageouscaterpillar.com/classes/yoga-recovery-for-runners/

Is the customization incorrect?

Hi there,

The use of the get_adjacent_post function seems to be incorrect. I checked the details here:

https://developer.wordpress.org/reference/functions/get_adjacent_post/

Since we are talking about the portfolio so we need to add the portfolio taxanomy at the end.

So maybe something like this:

$prev_post = get_adjacent_post( false, '', false, 'portfolio' );

Thank you.

The code above removes the previous navigation control completely.

Hi There,

In that case, would you mind giving us credentials so we can see your setup. Give us wordpress admin and FTP credentials on secure note. When you say it removes previous, do you mean all item doesn’t prev button?

Correct. All items don’t have previous button.

This is the grid page:
http://courageouscaterpillar.com/adventures/

Here’s one of the portfolio pages:

Since I’m now using Grid Essentials for the layout, I’m also noticing the navigation button to go back to the grid page (nine squares) is no longer working either. How do I set that correctly?

Hi there,

Sorry for the confusion, there may be some typo error. Please change it to this

$prev_post = get_adjacent_post( false, '', false, 'portfolio-category' );

The portfolio is not a taxonomy, it will not work.

Thanks!

Just tried this update. It doesn’t keep the navigation within the same portfolio category. The navigation previous goes through portfolio items in different categories.

Hi,

Sorry, it should be both true.

$prev_post = get_adjacent_post( true, '', true, 'portfolio-category' );

https://developer.wordpress.org/reference/functions/get_adjacent_post/

Thanks

This fix still isn’t keeping the navigation within the same portfolio category. Sometimes when it navigates to the correct portfolio there also aren’t any navigation buttons displayed.

I’m using Essential Grid to create display of portfolio items for selection on my page. Once the selected portfolio is displayed, I’d like to be able to navigate between all of the portfolio items of the same category using the standard next and previous navigation arrows.

Hi there,

  1. You should apply 'portfolio-category' on both next and prev, not just for prev, I went ahead and changed it to this
  $prev_post = get_adjacent_post( true, '', true, 'portfolio-category' );
  $next_post = get_adjacent_post( false, '', true, 'portfolio-category' );
  1. The Prev And Next navigation will only appear if there is an item to navigate to. The reason there is no navigation here http://courageouscaterpillar.com/item/bali-indonesia/ is maybe due to internal cache or conflict. It’s not a problem with the code, Wordpress itself can’t find the adjacent posts of that one. I traced it until I find the main query and nothing, so it must be an internal cache or transient issue on your host. Plus, the get_adjacent_post() is Wordpress’s reserved function https://codex.wordpress.org/Function_Reference/get_adjacent_post, the theme only displays the results given by Wordpress. Could you try cloning your site to a staging where there is no cache?

Thanks!