Unyson icon indicating copy to clipboard operation
Unyson copied to clipboard

Dynamic Sidebars for Custom Post Type

Open ankitaraikundalia opened this issue 12 years ago • 15 comments

Hi, I need to add different sidebars for a custom post type archive and single page. I don't see the custom post type listed in the drop-down for selecting groups in Dynamic sidebar extension. Is there any hook available for adding archive and single page of the Custom post type in the drop-down?

ankitaraikundalia avatar Nov 27 '14 14:11 ankitaraikundalia

All post types registered with 'public' => true should appear in the drop-down. Also you can use the fw_ext_sidebars_post_types filter to add other post types in drop-down.

player0k avatar Nov 27 '14 15:11 player0k

@player0k , Thanks for your reply. However, it allows me to assign different sidebars to only single page of custom post type. For archive of custom post type, it takes the setting from 'Archive Page' option in the drop-down. How do I assign different sidebars for different custom post type archives?

ankitaraikundalia avatar Nov 28 '14 07:11 ankitaraikundalia

@ankitaraikundalia,
The filter: 'fw_ext_sidebars_conditional_tags' was added in the last update of Unyson-Sidebars-Extension. It is available in the Unyson plugin version Use it to change conditional tags.

function _filter_fw_ext_sidebars_add_conditional_tag($data) {
    $data['is_archive_page_slug'] = array(
        'order_option' => 2, // (optional: default is 1) position in the 'Others' lists in backend
        'check_priority' => 'last', // (optional: default is last, can be changed to 'first') use it to change priority checking conditional tag
        'name' => __('Portfolio archive', 'fw'), //conditional tag title
        'conditional_tag'       => array(
            'callback'              => 'is_post_type_archive', //existing callback 
            'params'                => array('fw-portfolio') //parameters for callback
        )
    );


    return $data;
}
add_filter('fw_ext_sidebars_conditional_tags', '_filter_fw_ext_sidebars_add_conditional_tag' );

player0k avatar Dec 01 '14 07:12 player0k

@player0k I added the above code in hooks.php, but nothing happened.

ankitaraikundalia avatar Dec 17 '14 09:12 ankitaraikundalia

@ankitaraikundalia,

Thanks, the code in the message above was changed. There were some mistakes.

player0k avatar Dec 18 '14 13:12 player0k

@player0k , The code still doesn't work even after the change.

ankitaraikundalia avatar Dec 19 '14 06:12 ankitaraikundalia

@player0k - Any progress on this issue?

ankitaraikundalia avatar Dec 23 '14 11:12 ankitaraikundalia

@ankitaraikundalia, Sorry, but we can't reproduce this bug. http://screencast.com/t/CW3SDjZ5jOYX Could you please provide additional information about this issue.

player0k avatar Dec 23 '14 12:12 player0k

@player0k I added the code in inc/hooks.php, but I can't see Portfolio Archive option in the dropdown.

Below is the screenshot: dynamic_sidebar

ankitaraikundalia avatar Dec 23 '14 13:12 ankitaraikundalia

@ankitaraikundalia, Create the empty file in the your_current_theme_directory/framework-customizations/extensions/sidebars/hooks.php and put that code there. Also check if installation https://github.com/ThemeFuse/Theme-Includes was completed according to install instructions.

player0k avatar Dec 23 '14 15:12 player0k

@player0k I added the code in theme_directory/framework-customizations/extensions/sidebars/hooks.php I also checked the install instructions and it was done in the same way.

I also checked the code using Scratch theme [https://github.com/ThemeFuse/Scratch-Theme], but it doesn't work.

ankitaraikundalia avatar Dec 24 '14 06:12 ankitaraikundalia

@ankitaraikundalia, Make sure that you have last update of https://github.com/ThemeFuse/Unyson-Sidebars-Extension. The line with a filter.

player0k avatar Dec 24 '14 17:12 player0k

@player0k The problem is that I have v1.0.0 and filter code is missing in it. But the update of extension is not seen in Unyson Extensions Update in the backend, the reason why I don't have the updated version.

Check out the below screenshot: image

Also check out the manifest file of sidebars extension here. It shows the version to be 1.0.0 instead of 1.0.1

ankitaraikundalia avatar Dec 25 '14 16:12 ankitaraikundalia

But the update of extension is not seen in Unyson Extensions Update in the backend

Because the v1.0.1 was created as a simple tag, not as a release.

Fixed. Please check the updates page.

ghost avatar Dec 25 '14 17:12 ghost

@moldcraft Its working fine now after the update. Thank you.

ankitaraikundalia avatar Dec 26 '14 06:12 ankitaraikundalia