Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi @padams,

    I hope you are well today and thank you for your question.

    I can also see the Attachment Post Type has been ignored in the following Custom Sidebars plugin there fore i have notified the Custom Sidebars plugin developer to get his reply about why it has been ignored.

    The plugin developer will reply here shortly.

    static public function supported_post_type( $posttype ) {
    		$Ignored_types = null;
    		$Response = array();
    
    		if ( null === $Ignored_types ) {
    			$Ignored_types = get_post_types(
    				array( 'public' => false ),
    				'names'
    			);
    			$Ignored_types[] = 'attachment';
    		}
    
    		if ( is_object( $posttype ) ) {
    			$posttype = $posttype->name;
    		}
    
    		if ( ! isset( $Response[ $posttype ] ) ) {
    			$response = ! in_array( $posttype, $Ignored_types );

    Cheers,
    WPMU DEV

    Hi @padams,

    this code is in the plugin since the first version. Personally I would add attachments, but with almost 560.000 downloads we cannot simply change these defaults because a developer changed his mind 😉

    We have added a rather easy way to add the attachment post-type back via a custom filter. Add this snippet to your themes “function.php” to enable custom sidebars for attachments:

    function sidebars_is_posttype_supported( $def_value, $posttype ) {
    	if ( 'attachment' == $posttype ) { return true; }
    	else { return $def_value; }
    }
    add_filter( 'cs_support_posttype', 'sidebars_is_posttype_supported', 10, 2 );

    Hope this helps!
    Philipp from WPMU DEV

    Hi @stracker.phil,

    Thanks for your quality reply and sharing the solution.

    @padams could you please try using the solution posted by @philipp in his previous reply and let us know how it works for you?

    Regards,
    WPMU DEV

    Thread Starter padams

    (@padams)

    I will give it a shot. However commenting out the line

    $Ignored_types[] = ‘attachment’;

    Worked great. Not sure why you guys are reluctant to make that change. i can’t find any problems with the plugin when i do so.

    Thanks again!

    I’ll add the suggestion to our review-list and maybe attachments will become available by default in one of the next versions.

    I just want to remind you that changes to the plugin code will be overwritten when you update the plugin. So keep in mind to make that change again after updating. The filter function is doing exactly the same as commenting out that line (it is even optimized to have no impact on performance)

    Thanks, Philipp from WPMU DEV

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Is Attachment Post Type Not support?’ is closed to new replies.