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
- Where to put my code: plugin or functions.php?
- Autoloading & Namespaces in WordPress Plugins & Themes: Can it Work?
- framework for plugin/theme options panel? [closed]
- How to get the path to the current theme?
- ajaxurl not defined on front end
- What process do you use for WordPress development? [closed]
- Why does WordPress use outdated jQuery v1.12.4?
- What is the advantage of using wp_mail?
- Should Plugin Folders Include a Blank index.php File?
- How to include jQuery and JavaScript files correctly?
- Custom Widget function in Plugin not working?
- Single functions.php or split into many small files?
- How can I configure Docker for developing and deploying a custom theme?
- Where to store PHP files created by plugin / themes
- Adding Widget form fields dynamically
- Hook in wp.media to add a new tab
- What is the correct way to build a widget using OOP
- How to post data to same page in wordpress
- What is an alternative method to the WordPress private _doing_it_wrong() function
- Understanding WordPress functions’ naming conventions
- Widget won’t be activated
- Woocommerce Custom Checkout
- Caption Shortcode: what filter to change the image size?
- Looping single post in a theme
- Font Awesome stopped showing icons, shows &# text instead [closed]
- Create new sidebars trough admin post/page metabox
- Merge Codes using redux framework
- To remove rendering of menus and header, plugin or theme?
- To remove rendering of menus and header, plugin or theme?
- Managing Custom Designed Content
- WordPress permalink setting
- Custom theme and plugin updating
- Issue on Getting Images URL of the Post Gallery
- Best practice: What belongs in theme and what in plugin for large eCommerce website
- Downloading Generated XML File
- How can I add recent posts to menu like mashable
- Detect each active instance of a widget
- Is there a general way to get a themes primary colour?
- variable created in page.php is null inside of header.php
- Issue on Getting WP Gallery Items In cpt-single.php As Attachments
- Generate activation url
- Adding class to the parent of current-post-ancestor / current-menu-parent / current-post-parent
- problem with blank page
- How to Register/Link to .js Files in WordPress Dynamicaly in Header.php
- Get fields of a widget
- Display Data’s metabox in page
- Updating Style From WP Options Setting Page
- Ajax functions – no access to wp-admin.php only online
- Create and style menu
- How do I create Widget within plugin that uses its own class?
- Best practice to include custom user styles in widgets
- WordPress Beginer to Guru [duplicate]
- Saving multiple fields as array
- How to specify widget order or css name via script?
- If I want to create new taxonomies (e.g. Project / Documents / Etc…) is it better to create them in the theme’s functions.php or within a plugin? [duplicate]
- How to add something after a function
- Add the title of a widget as an ID – for anchor links
- append code after the_content not working
- How can I make my website with wordpress having on-spot editing feature as compared to concrete5 CMS?
- Problem with Poedit [closed]
- 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
- Is Explicit Versioning a better alternative to Semantic Versioning for wordpress?
- Invalid Menu Items
- how many rupee or dollar charge to client to make theme [closed]
- Gutenberg text field validation
- How to get the value entered in the input field in wordpres
- how to catch a data from a array in WordPress
- How are themes and plugins localized using the gettext GNU framework?
- How react js and other Javascript Technologies works on WordPress plugin?
- Theme, Plugin or Both?
- How will i add an option under customizer the event calendar section?
- Is there any other ways to replicating changes on live from staging without pushing from git
- How to create A – Z List with pictures?
- Is it possible to add Custom Dashboard Widgets to Custom Admin Menu Page?
- Hook a search form anywhere on the site, using a custom plugin
- Why isn’t custom sidebar panel not showing up in the Gutenberg Editor?
- Fetch Custom Woocomerce filed data and check the data avialble in Wp-user table as nicname or username using function.php
- Remove Gutenberg Buttons Block
- Capture the Selected Radio Button Value between two files in wordpress theme
- How to create new title and its description inside a section in WP Customizer?
- How to customize password reset message page on success if no error in password reset
- Sticky bar with filter button and product count
- All Pages and Post are redirecting to 404 Not Found in wordpress
- useBlockProps() nests wrapper with class name inside block wrapper in the editor
- User set default settings for a Block in Site Editor
- How do I cause plugin patterns to appear in the widget areas?
- WordPress Block with Interactivity API e Preact Component