How to display only some widgets of a sidebar?

If what you want is “to break up a sidebar over three containers”, then you don’t really need to rebuild dynamic_sidebar() to do it. There is a filter called dynamic_sidebar_params that can be leveraged to break up the sidebar. function add_closing($params) { $params[0][‘after_widget’] = $params[0][‘after_widget’].'</div><!– close wrapper-thing –>’; return $params; } add_filter( ‘dynamic_sidebar_params’, function ($params) … Read more

Loop through all posts, show attachment if there

You can’t use the_title() as you haven’t set up the post data. Instead for the title you need to use: $post->post_title; To get the attachments you can then use get_children() something like this: $args = array( ‘numberposts’ => 1, ‘post_parent’ => $post->ID, ‘post_type’ => ‘attachment’ ); $attachments = get_children( $args ); foreach($attachments as $attachment) { … Read more