Why does the global value not work in the functions file?
-
Hello,
I have been pulling my hair out trying to fix this, I want to be able to give the user options to choose how many widget areas there are, but I cannot pull the value in from the options into the functions file using the global method you have provided.
My code –
function everything_widgets_init() { global $redux_builder_chaz1993; $totalCol = $redux_demo['opt-layout']; $colCount = 1; while ( $colCount <= $totalCol ): register_sidebar( array( 'name' => esc_html__( 'Home Box - Column ' . $colCount, 'everything' ), 'id' => 'column-' . $colCount, 'description' => esc_html__( 'Add widgets here.', 'everything' ), 'before_widget' => '<section id="%1$s" class="widget %2$s">', 'after_widget' => '</section>', 'before_title' => '<h2 class="widget-title">', 'after_title' => '</h2>', ) ); $colCount++; endwhile; } add_action( 'widgets_init', 'everything_widgets_init' );
It does what I need when I change $totalCol to 4, which is the highest value it can be, how can I get the option setting working here within the functions file?
I haven’t got a massive amount of knowledge with PHP so can’t seem to figure this one out ??
Any help would be awesome!!!
Thanks
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Why does the global value not work in the functions file?’ is closed to new replies.