function enable_posts_sidebars() { //get all posts $posts_page = get_posts(array('post_type' => 'page', 'numberposts' => '-1')); $posts_post = get_posts(array('post_type' => 'post')); $posts = array_merge($posts_page, $posts_post); foreach ($posts as $key => $post) { $post_meta_sidebar = json_decode(get_post_meta($post->ID, 'post-sidebar', true)); // var_dump($post_meta_sidebar);die; $pages_posts = ""; if (!empty($post_meta_sidebar) && is_object($post_meta_sidebar)) { foreach ($post_meta_sidebar->name as $pms) { $post_sidebar_name = hiphenize($pms); $pages_posts .= $post->post_name . " "; if (!empty($post_sidebar_name)) { register_sidebar(array('name' => $post_sidebar_name, 'id' => $post_sidebar_name, 'description' => 'This sidebar is exclusive for: ' . $pages_posts, 'class' => 'footer-sidebar', 'before_widget' => '<div id="%1$s" class="widget %2$s">', 'after_widget' => '</div>', 'before_title' => '<h2 class="widget-title">', 'after_title' => '</h2>')); } } } } }
echo hiphenize($sidebar); ?> -sidebar-box { width:<?php echo $post_sidebar->width[$ind] ? $post_sidebar->width[$ind] : 0; ?> %; display:inline-block; } } </style> <div id="content-<?php echo hiphenize($sidebar); ?> -sidebar-box" class="virtual-sidebar"> <?php dynamic_sidebar(hiphenize($sidebar)); ?> </div> <?php } else { $sbcount++; } ?> <?php } ?> </div> </div> <?php