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
- Autoloading & Namespaces in WordPress Plugins & Themes: Can it Work?
- What process do you use for WordPress development? [closed]
- What is the advantage of using wp_mail?
- Should Plugin Folders Include a Blank index.php File?
- Adding Widget form fields dynamically
- What is the correct way to build a widget using OOP
- Calling the widget id of a mult-instance widget from inside the widget?
- Should I create a theme or a plugin?
- Include third party Javascript library which is not included in WordPress
- Where do I start from
- WP 3.3 Tooltips API?
- wp_remote_get doesn’t work with secure connections https?
- Authoritative answer on which boots first – Plugins or Themes?
- How to Add Font Awesome Icons to WordPress Menus?
- How to Use WordPress Color Picker API in Custom Post Type Metabox
- Custom theme sufficient or custom plugin neccessary for this feature set?
- Registering Sidebars and Sidebar Widgets. Sidebar Widgets Not Displaying
- Edit the output of wp_widget_rss_output()
- How to create custom home page via plugin?
- How to debug WordPress correctly?
- Featured Image not showing in admin
- How to add multiple copies of a widget from “available widgets”
- Whats the difference between blog_info(‘stylesheet_url’) difference get_stylesheet_uri()
- Paging on a future post loop?
- How to pass custom options from widget form to widget update callback?
- How i can get widgets areas working in customizer?
- How to check if a stylesheet is already loaded?
- Problem with is_active_sidebar?
- Is Dreamweaver CS5 a serious choice for theme/plugin development?
- Widget update function not saving values
- Change template dynamically
- WordPress add_admin_page not working even parameters are correct?
- Get Current Menu Location inside Nav_Walker
- Can’t see widget areas in my customizer
- Widget is to be compatible with all themes
- Howto: Use Custom Post Types as Submenu Items in Admin
- Extending theme PHP class in plugin
- what is the difference between these phares?
- “Add A Widget” button in the Customizer
- How to hide or rename “X” and “x-child” references in website source?
- Dynamically creating classes for Widget API
- 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?
- Adjust query on single
- Using password protection to load different page elements?
- Anyone using unzip_file successfully? It uploads the zip but doesn’t extract it!
- 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?
- Create new sidebars trough admin post/page metabox
- 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 Register/Link to .js Files in WordPress Dynamicaly in Header.php
- 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 will i add an option under customizer the event calendar section?
- How to create A – Z List with pictures?
- Is it possible to add Custom Dashboard Widgets to Custom Admin Menu Page?