You probably need to use output buffering, if I understand your question correctly.
Try something like this:
ob_start();
dynamic_sidebar('sidebar-id');
$sidebar = ob_get_contents();
ob_end_clean();
That will put the output of the sidebar into the variable $sidebar, which you can then process and return from your filter on the page content.
Related Posts:
- Get list of all registered sidebars
- What is the difference with get_sidebar and dynamic_sidebar?
- Hooking a function onto the sidebar?
- Changing name of sidebar widget
- Getting post-thumbnails from another WP site
- Get custom side bar on custom post archive page
- bloginfo(‘stylesheet_directory’) vs. get_stylesheet_directory_uri() and include(‘file.php’) vs. get_template_part()
- How do I hook a sidebar via add_action?
- Display comment form of specific page in sidebar
- Category specific months list in sidebar.php
- Is there possibility to Customize the present theme adding sidebars
- Get a sidebar at the top of the page
- Custom sidebar not showing in the dashboard
- Sidebar random author spotlight
- Main Sidebar Dispappeared – What could possibly cause this?
- Change which sidebar get_sidebar() gets from functions.php
- Why and how is twentythirteen adding a margin-top to my footer?
- Load same sidebar multiple times
- Backend menu sidebar collapsed by default every time? [duplicate]
- Get sidebars depending on page
- Unregister sidebar from Child-Theme
- How can I hide the sidebar on specific pages?
- Display sidebar if blog
- How can you add a link to a sidebar description?
- unregister_sidebar() in stand-alone theme not working
- Same date is repeating on my custom ‘Most Recent Posts’ on sidebar
- Corrupt WordPress Design/Appearance [duplicate]
- How are Dynamic Sidebar Widgets rendered
- Output dynamic_sidebar into PHP
- WP for main site and two blogs – implementation
- How to list custom post types in a secondary sidebar?
- Dividing widgets in sidebar?
- Paging in a sidebar mini loop
- How to add an entry to the Page/Post Settings Sidebar? [duplicate]
- Include a sidebar on the static front page of twenty thirteen
- How to get the sidebar HTML content?
- Adding Multiple Sidebars
- How to increase maximum number of sidebars support?
- if statement in sidebar.php checking page id or template or title
- Unable to call specific dynamic_sidebar
- Display smilies in Sidebar, too?
- How to enable the default sidebar area?
- Remove Sidebar from WordPress [closed]
- Call dynamic sidebar by name not ID
- How to send data to sidebar?
- Gutenberg sidebar example does not update meta field in the database
- Implementing Sticky Kit on WordPress
- Check if sidebar is rendered?
- Not Getting Sidebar
- Where is dynamic_sidebar content defined?
- Why does my sidebar get dragged down on this specific uid?
- finding sidebar content in wordpress
- Extra copy of sidebar appears in footer
- Create an array of “read next” posts using a dynamic offset
- How do you control sidebars when there’s no get_sidebar in templates?
- Can Sidebar’s widget retrieve information from content area?
- Twenty Thirteen get_sidebar Question
- register_sidebar_widget is deprecated since version 2.8
- get dynamic_sidebar() value in array in wordpress
- Sidebar not showing up on homepage
- display specific sidebar for each role
- Change twentytwelve sidebar responsive relocation?
- Split the content of the_content();
- How to troubleshoot Sidebar not being generated
- How to remove the ‘Archives’ title and list and the ‘Meta’ title
- Can the Twenty Eleven theme have a Main Sidbar at all?
- Select a Sidebar from Page Creation
- Why is my custom sidebar always open on the widgets screen in Admin?
- Custom sidebars – get_sidebar() problems
- Header image is overlapping sidebar?
- Content not showing up when using custom template + sidebar
- How to assign a sidebar to a WordPress page when none was there before
- How do I set is_active_sidebar?
- Customizer doesn’t recognise sidebar
- How do I edit the side-bar (doesn’t seem to be a menu)?
- sidebar / widget wont show
- Sidebar widgets are looping out of the sidebar wrapper
- A way to have some per sidebars settings integrated with the native sidebar/widgets UX?
- Children Pages Displaying Only Intermittenty
- Extra sidebar in Twenty fifteen
- sidebar not displaying when using get data
- Why isn’t my registered sidebar showing up in the admin?
- More than one dynamic sidebar
- Can’t find link to add content to pages
- How to add banners in sidebar of my theme [duplicate]
- Sidebar does not display on blog page, but fine with static pages
- My side bar is missing from new pages.
- Template is different with and without comments
- Placing video content into a sidebar
- different contents and same sidebar approach?
- How do I store get_sidebar in a varaible? [duplicate]
- How to create another sidebar to be shown on another page?
- Images in Woocommerce Product Sidebar [closed]
- How do I load my site without the side bars? This is for an app
- ReadWriteWeb-like sidebar scrolling
- How do I move the sidebar more to the right in TwentySeventeen?
- Remove Sidebar for Pages on Canvas Wootheme [closed]
- How can I add custom sidebar to my theme? [closed]
- how do I change the side bar content?
- How to hide sub categories in sidebar [closed]