-
AuthorPosts
-
April 26, 2024 at 12:08 pm #1440945
Is there a way to have a portfolio layout for all entries?
Sidebar or No sidebar
Specific Sidebar for Portfolio Entries
Custom Builder structure
Etc…I need to define how all portfolio entries should look and have a custom layout, for example no sidebar and then none has a sidebar, or custom sidebar and all of the will use that sidebar, etc…
Thanks.
April 28, 2024 at 4:58 pm #1441203Hey peterolle,
To have a custom sidebar that only shows on portfolio posts, first create a custom widget area, in this example I named it “portfolio sidebar” and added the text widget:
then ensure that the sidebar i enabled on single post items:
Then add this code to the end of your child theme functions.php file in Appearance ▸ Editor:add_filter("avf_custom_sidebar", function($custom_sidebar) { if(is_single() && get_post_type() === 'portfolio'){ $custom_sidebar = "portfolio-sidebar"; } return $custom_sidebar; }, 10, 1);
and the sidebar will show only on portfolio posts:
Best regards,
MikeApril 28, 2024 at 5:27 pm #1441206Thank you Mike.
I do not use sidebar in single posts, so I can’t enable that.
I can’t have a sidebar just in portfolio items and control that?
Also, how can I disable the sidebar, just in portfolio items?
- This reply was modified 6 months, 3 weeks ago by peterolle.
April 28, 2024 at 7:14 pm #1441212Hi,
If in the theme settings you are going to have no sidebar as the option for Sidebar On Single Post Entries
but still want a sidebar to show only on portfolio posts, add this code to the end of your child theme functions.php file in Appearance ▸ Editor:function enable_sidebar_on_portfolio_posts_when_disabled_in_theme_settings($layout, $post_id) { if( is_single() && get_post_type() == 'portfolio') { $layout['current'] = $layout['sidebar_right']; $layout['current']['main'] = 'sidebar_right'; } return $layout; } add_filter('avia_layout_filter', 'enable_sidebar_on_portfolio_posts_when_disabled_in_theme_settings', 10, 2);
That would show the Sidebar Pages or Displayed Everywhere widget area:
If you then want a custom portfolio sidebar widget area to show, then follow the steps above.Best regards,
Mike -
AuthorPosts
- You must be logged in to reply to this topic.