Replace Content of Sidebar on Custom Post Type

After a lot of trying and testing, I think I’ve found a solution: add_filter( ‘sidebars_widgets’, ‘exchange_sidebars’, 10); function exchange_sidebars( $sidebars_widgets ){ global $post; // Define the sidebar which should be exchanged $selected_sidebar=”sidebar-1″ // IF we are on a custom post type // AND it is a Child Page (= page has post_parent) // THEN change … Read more

Use atributes of shortcode in get template part

The $atts in your template part (templates/show-taxonomy.php) that you passed to shortcode_atts() is not defined, so you need to define it by passing it via the third parameter for get_template_part() like this: get_template_part( ‘templates/show-taxonomy’, ”, array( ‘atts’ => $atts ) ); Then in the template part, use $args[‘atts’] to access the shortcode parameters: $atts = … Read more