Sidebar position issue for custom post types
Hello!
I noticed that i can't change sidebar position for archive templates for custom post types (e.g. WooCommerce ) but it works fine for single products.
Is there any way to fix this please? Maybe, we can use https://codex.wordpress.org/Function_Reference/is_post_type_archive in sidebar extension?
Thank you again for this great framework :)
Hello,
Please provide screenshots or video or the exact steps to reproduce (I am not an expert in Sidebars extension)
Hi, @moldcraft , here are few steps (i'm using default Scratch theme in this case):
-
On Appearance > WIdgets screen, add "Right sidebar" to All pages (works fine)
-
Add Left Sidebar for Specific Pages > Shop (woocommerce plugin should be active). It doesn't change a sidebar position for this page

Basically, i can't change sidebar position for this page even i choose Pages > Product or Category > Product category target

This happens for all custom post types, not for WooCommerce Products only, e.g. it is not possible to change sidebar position for Custom Post Type / Archive page, try to change
Thank you :)
I think the problem is here. I am trying to figure out how it works and how to fix it. If you know how, please share (or pull request).
is missing more , own post types and woo shop homepage
I made my own plugin for widgets assignment and had issues with this ,
these are missing peaces I used in plugin wich will also fix this issue
method for custom post types
/**
* get post types for page info
*/
protected function is_thz_post_type( $post = NULL )
{
$all_custom_post_types = get_post_types();
if( is_front_page() || is_search() || is_404() || is_home() ){
return false;
}
// there are no custom post types
if ( empty ( $all_custom_post_types ) ){
return false;
}
$custom_types = array_keys( $all_custom_post_types );
$current_post_type = get_post_type( $post );
// could not detect current type
if ( ! $current_post_type ){
return false;
}
return in_array( $current_post_type, $custom_types );
}
and these 2 inside the get_current_page_reset method
if ( class_exists( 'WooCommerce' ) ) {
if( is_shop() ){
$pageid = get_option( 'woocommerce_shop_page_id' );
$data['type'] = 'pt';
$data['sub_type'] = $data['type'].'_page';
$data['id'] = $pageid ;
$data['slug'] = $data['sub_type'].'_'.$pageid ;
$data['setby'] = 'is_shop()';
if(in_array($data['slug'],$assigned_pages) || in_array($data['sub_type'],$assigned_pages)){
return $data;
}
}
}
if ( $this->is_thz_post_type() ){
$data['type'] = 'pt';
$data['sub_type'] = $data['type'].'_'.get_post_type();
$data['id'] = get_queried_object_id();
$data['slug'] = $data['sub_type'].'_'.$data['id'];
$data['setby'] = 'is_thz_post_type()';
if(in_array($data['slug'],$assigned_pages) || in_array($data['sub_type'],$assigned_pages)){
return $data;
}
}
note I made my own output but you get the idea
@moldcraft if you need my plugin as ref skype me , is much more extended than Unyson sidebars but the logic is based on get_current_page_preset() method
@moldcraft Thank you for a great possibility to become Unyson tester :)
@danyj @moldcraft I suggest to add new group "Archives", because any of custom post type can have own archive page and it is not enough just one Archive category
I uploaded my changes for this repo https://github.com/ThemeFuse/Unyson-Sidebars-Extension here
https://drive.google.com/open?id=0Bz6XVdLE4r1fTG1FaDM4YTBlcU0
what were done:
- Added WooCommerce support
- Added Tag taxonomy support
- Added (any) Custom Post Type Archive support
please let me know what do you think
this is how my plugin organizes the pages
http://take.ms/CvAyl
@danyj looks good 👍
@WPJobs I included your changes https://github.com/ThemeFuse/Unyson-Sidebars-Extension/commit/acd0053265cbaec79c4de4eac7b9ccc00ba1c6e7 Thank you
Your changes fixes this issue please close it.
Thank you so much, hope an update for Unyson will be released soon. Have a great day!
@WPJobs Can you tell me please how can I test this ?
@andronic90 Sorry for late reply, i was on vacation :)
Try to install WooCommerce, then go to Appearance > Widgets and set any sidebar position for Shop page or WooCommerce category / tag. I tested the changes that i made and now it works without issues, please let me know if i can help more
Hello @WPJobs , this works only for "Shop page", for categories and tags works and in previous version. For archives I tested inThe Core theme and this didn't work, for example for the archive /?post_type=post, for date - this is too archive, /?author=1 this is the same as archive. Please choose here only the posts that have archives : https://github.com/ThemeFuse/Unyson-Sidebars-Extension/commit/acd0053265cbaec79c4de4eac7b9ccc00ba1c6e7 , for example I think "Page" have no sense to include here https://www.screencast.com/t/G7268U2GN6jL .
@andronic90 you're right, please test this https://drive.google.com/open?id=0Bz6XVdLE4r1fTnFqdGFvZm8wVTQ, i removed Pages from archives.
Yes, previous version worked with Post archives, but not with third-party custom post types, for example, try WeDocs plugin, it was impossible to change sidebar for Docs post type, and now it fixed
Author archive page is already in the list, i believe it should be not moved to global Archives
I downloaded the version that you send, and now the "archives" disappear from widgets list, please verify if the version that you send is the latest. Thank you
i'm so sorry, this is a right link https://drive.google.com/open?id=0Bz6XVdLE4r1fanR6STgwQkpicW8
Hello @WPJobs , can you test now : https://github.com/ThemeFuse/Unyson-Sidebars-Extension , I extracted only post that have : "has_archive" and restore the "Archive Page" - for pages ad date, author and others pages
@andronic90, it works fine for me, thank you so much!