Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter boro2g

    (@boro2g)

    Its worth noting, if I iterate through the registered sidebars using

    <?php foreach ( $GLOBALS['wp_registered_sidebars'] as $existingSidebars ) {
                  echo ucwords( $existingSidebars['id'] );  } ?>

    I see:
    Sidebar-1
    Sidebar-2
    Sidebar-3
    Sidebar-4
    Sidebar-5

    I’ve tried replacing
    `<?php dynamic_sidebar( ‘top-right-column’ );?>’
    with
    ‘<?php dynamic_sidebar( ‘Sidebar-3′ );?>’

    But still get the same thing unfortunately.

    Hi @boro2g,

    Greetings and thanks for posting on the forums.

    I could reproduce the same issue on my test site.

    The issue has been fixed in the plugin and will be released with the fix in next plugin version.

    In the meanwhile to fix it in the current Custom sidebars plugin version 1.3.1 you can just move the code from line number 171 to 179 on line number 135 in the following plugin file

    wp-content/plugins/custom-sidebars/customsidebars.php

    Best Regards,

    Thread Starter boro2g

    (@boro2g)

    Thats resolved the issue – thanks!

    FYI if anyone else needs the fix, the change left the determineReplacements function beginning:

    function determineReplacements($defaults){
    		//posts
    		if(is_single()){
    			//print_r("Single");
    			//Post-type sidebar
    			if($this->replacements_todo > 0){
    				$post_type = get_post_type($post);
    				foreach($this->replaceable_sidebars as $sidebar){
    				if(isset($defaults['post_type_posts'][$post_type]) && isset($defaults['post_type_posts'][$post_type][$sidebar]))
    					$this->replacements[$sidebar] = array($defaults['post_type_posts'][$post_type][$sidebar], 'defaults', $post_type);
    					$this->replacements_todo--;
    				}
    			}
    			//Post sidebar
    			global $post;
    			$replacements = get_post_meta($post->ID, $this->postmeta_key, TRUE);
    			foreach($this->replaceable_sidebars as $sidebar){
    				if(is_array($replacements) && !empty($replacements[$sidebar])){
    					$this->replacements[$sidebar] = array($replacements[$sidebar], 'particular', -1);
    					$this->replacements_todo--;
    				}
    			}
                            //Parent sidebar
                            if($post->post_parent != 0 && $this->replacements_todo > 0){
                                $replacements = get_post_meta($post->post_parent, $this->postmeta_key, TRUE);
                                foreach($this->replaceable_sidebars as $sidebar){
                                        if(!$this->replacements[$sidebar] && is_array($replacements) && !empty($replacements[$sidebar])){
                                                $this->replacements[$sidebar] = array($replacements[$sidebar], 'particular', -1);
                                                $this->replacements_todo--;
                                        }
                                }
                            }
    			//Category sidebar
    			global $sidebar_category;
    			if($this->replacements_todo > 0){
    				$categories = $this->getSortedCategories();
    				$i = 0;
    				while($this->replacements_todo > 0 && $i < sizeof($categories)){
    					foreach($this->replaceable_sidebars as $sidebar){
    						if(!$this->replacements[$sidebar] && !empty($defaults['category_posts'][$categories[$i]->cat_ID][$sidebar])){
    							$this->replacements[$sidebar] = array($defaults['category_posts'][$categories[$i]->cat_ID][$sidebar],
    																	'category_posts',
    																	$sidebar_category);
    							$this->replacements_todo--;
    						}
    					}
    					$i++;
    				}
    			}
    			return;

    Hi @boro2g,

    You are most welcome.

    Have a great day!

    Cheers,

    Ey Guys,

    The solution you posted works, but it is not recommendable because it changes the sidebars selection priority, so it will mess some other pages of your site.

    The proper bug fixing is updating the line 175 of customsidebars.php

    if(isset($defaults['post_type_posts'][$post_type]) && isset($defaults['post_type_posts'][$post_type][$sidebar]))

    adding a new check

    if(!$this->replacements[$sidebar] && isset($defaults['post_type_posts'][$post_type]) && isset($defaults['post_type_posts'][$post_type][$sidebar]))

    This will be fixed this way in the next version ??

    Cheers

    Hi @marquex,

    Thanks for replying and posting the better solution! Glad I could offer a quick fix in the meantime.

    Cheers,

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Post specific sidebar doesnt show, instead it shows the default’ is closed to new replies.