Using Advanced Custom Fields Create WYSIWYG Fields “Right Sidebar” (id right_sidebar) and/or “Left Sidebar” (id left_sidebar).
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
function jma_custom_sidebar($side){ $content = get_field( $side.'_sidebar'); $content = apply_filters('the_content', $content); $content = str_replace(']]>', ']]>', $content); echo $content . '<div style="clear: both; margin-bottom: 20px"></div>'; } /** * Call our sidebar functions based on the * current position and current sidebar layout. */ function jma_custom_sidebars( $position ) { // Get current sidebar layout $layout = themeblvd_config( 'sidebar_layout' ); if( $position == 'left' ) { // Display any sidebars to be located on the LEFT // based on the current sidebar layout. // Display the left sidebar if( $layout == 'sidebar_left' || $layout == 'double_sidebar' || $layout == 'double_sidebar_left' ) { do_action( 'themeblvd_fixed_sidebar_before', 'left' ); if(get_field('left_sidebar')) jma_custom_sidebar('left'); else themeblvd_display_sidebar( 'sidebar_'.$position ); do_action( 'themeblvd_fixed_sidebar_after' ); } // Display the right sidebar if there is a // double sidebar over on the left. if( $layout == 'double_sidebar_left' ) { do_action( 'themeblvd_fixed_sidebar_before', 'right' ); if(get_field('right_sidebar')) jma_custom_sidebar('right'); else themeblvd_display_sidebar( 'sidebar_right' ); do_action( 'themeblvd_fixed_sidebar_after' ); } } else if( $position == 'right' ) { // Display any sidebars to be located on the RIGHT // based on the current sidebar layout. // Display the left sidebar if there is a // double sidebar over on the right. if( $layout == 'double_sidebar_right' ) { do_action( 'themeblvd_fixed_sidebar_before', 'left' ); if(get_field('left_sidebar')) jma_custom_sidebar('left'); else themeblvd_display_sidebar( 'sidebar_left' ); do_action( 'themeblvd_fixed_sidebar_after' ); } // Display the right sidebar if( $layout == 'sidebar_right' || $layout == 'double_sidebar' || $layout == 'double_sidebar_right' ) { do_action( 'themeblvd_fixed_sidebar_before', 'right' ); if(get_field('right_sidebar')) jma_custom_sidebar('right'); else themeblvd_display_sidebar( 'sidebar_'.$position ); do_action( 'themeblvd_fixed_sidebar_after' ); } } } function jma_template_redirect(){ if(is_page() && function_exists('get_field') && (get_field('right_sidebar') || get_field('left_sidebar'))){ remove_action( 'themeblvd_sidebars', 'themeblvd_fixed_sidebars' ); add_action( 'themeblvd_sidebars', 'jma_custom_sidebars' ); } } add_action('template_redirect', 'jma_template_redirect'); |