Creating new query objects is not a good idea in this situation. Try simply getting the pages and using those objects to serve up the widget areas:
add_action( 'widgets_init', 'my_243057_widgets_init' );
function my_243057_widgets_init() {
/**
* Get only published page objects
* @link: https://codex.wordpress.org/Function_Reference/get_pages
*/
$pages = get_pages();
foreach ( $pages as $page ) {
register_sidebar( array(
'name' => 'Widget name',
'id' => 'widget-id-' . $page->ID,
'description' => __( 'Widget for page: ' . $page->post_title ),
'before_widget' => '<div>',
'after_widget' => '</div>',
'before_title' => '',
'after_title' => '',
) );
}
}
Related Posts:
- Customizer: widget-synced triggers twice
- Customizer Not Saving Options
- Can I individually style items in the backend widget list?
- How to limit number of number of categories displayed by categories widget
- WordPress dynamic widget by location?
- Impossible to declare box-shadow with wp.customize?
- How to embed or integrated a custom WordPress Widget into the theme?
- Post Pagination does not working on WP-Query
- wp_register_sidebar_widget in loop within a plugin?
- grouping my widgets wordpress
- ajaxurl not defined on front end
- How to post data to same page in wordpress
- Understanding WordPress functions’ naming conventions
- jQuery in header or footer
- register_sidebar ignores ‘id’ and ‘class’
- Add content to widget title in admin area within the widget?
- Has anyone managed to integrate the wp_editor inside a widget?
- Show a user their recently viewed posts
- Escaping built-in WP function return strings
- Help adding image upload functionality to widget
- Add new user and add meta at once
- Multiple entries in get_option results? or why is _multiwidget set to 1?
- How to Display Custom Post Type’s Gallery (images ) in Through WP_Query
- Using Ajax call in jQuery doesn’t work in widget
- Error : “Updating failed: The response is not a valid JSON response” with custom shortcode
- What’s the better way to add an inline script?
- Is there a need to do apply_filter(‘widget_title’, $instance[‘title’]) or any other ‘widget_xxx’ filters?
- Metabox Not Showing on Custom Post Type But On Pages and Post
- Dynamic content in a widget
- Backslashes being stripped from CSS
- How to determine if the current file is loaded in a plugin or in a theme?
- Filter, or any way to dynamically change theme screenshot image?
- How to integrate plugin in WordPress theme
- Finding the paragraphs in content
- Which action is triggered when a theme was modified?
- How to avoid loading same script twice?
- Sidebar widget to show popular post not working?
- WP_Query returns no results
- Finding posts containing matching array elements in a meta field usign WP_Query
- Should action callbacks start with a verb?
- How to Create Custom HTML Tag on Editor in `Text(HTML)` mode
- Is It Always a Best Practice to Decouple the Frontend from the Admin Area When Developing a WordPress Application?
- How to render a time-of-day string like ’16:42′ with a site’s chosen time format?
- Are block templates incompatible with serialize_blocks?
- How to filter users list on user_status field with get_users()
- Add a class to a dynamic sidebar’s wrapper
- Can Page Templates be Applied to Archive and Post Templates?
- Is there some way to provide the user a list of existing content in a CPT
- Change the look and feel of admin pages
- Form doesnt save to database
- Notice: Trying to get property ‘term_id’ of non-object
- What is the proper method of using global $post?
- How to change title tag at page after loaded post?
- WordPress custom taxonomy check box to dropdown
- Selectively update themes in WordPress multisite
- Why does my widget break other widgets?
- Using a multiple element in widget form
- Plugin is not generating title tags on any pages or posts
- Is it necessary to do validation again when retrieving data from database?
- Update Data parameter of a wp_localize_script() call
- get_the_tags with separator control?
- How to only load css for used blocks on frontend
- Add child pages to submenu automatically
- Why in this archive page that call query_posts() function show only the last 10 posts?
- Custom Stylesheet instead of Inline CSS for WordPress Customizer API Overrides
- Add SideBar/Widgets Just Below the Post
- PHP File_exist() not working – Checking if File Exist in WordPress Theme Directory
- Why would you use esc_attr() on internal functions?
- Invalid hook call on save, not edit when using swiper slider
- How to find where an object first instantiatiation
- Full documentation about $args for register_rest_route?
- How to get terms for taxonomy
- What’s the right way to implement functions in footer.php
- How to remove/replace current page template?
- Using password protection to load different page elements?
- WP_Query order posts by category
- Widgets are not displaying in the admin panel
- WordPress Favicon not Working For Images/Videos/PDFs
- How can we upload file to root directory of wordpress
- How can we stop showing short code in create or edit post section
- Is it possible to develop themes and plugins locally while still allowing content to be updated directly in the admin dashboard?
- Quick Draft widget (dashboard.php) using custom post_type
- Error Connecting to Database WHEN Installing WordPress on XAMPP [Tried All the Usual Stuff] (Pics Included)
- Don’t print customizer styles when no setting has been used
- How can I measure CPU and RAM used by my theme or plugin
- If user is logged-in display/hide widgets ( siteorigine) [closed]
- set a custom post type to a taxonomy term programmatically in metabox
- Custom premium registration form and profile page for a WordPress Web Application
- My enqueue admin style function doesn’t work because of ?=ver
- How to destroy or dispose wordpress uploder/manager?
- To remove rendering of menus and header, plugin or theme?
- How can I add recent posts to menu like mashable
- Is there a general way to get a themes primary colour?
- How to specify widget order or css name via script?
- Best Way to Inventory the Media Library of a 200+ Multisite Installation?
- Loading jQuery library from WordPress admin
- Using tag or inline style attribute?
- how to insert content into wp_head after loop_end
- How react js and other Javascript Technologies works on WordPress plugin?
- Remove Gutenberg Buttons Block