Use get_the_ID() instead of the_ID(). the_ID() will echo’ed the ID of posting:
<option value="<? the_ID(); ?>" <?php selected(get_the_ID(), $instance['post_to_display']); ?>><?php the_title(); ?></option>
Related Posts:
- SELECT field options disappear when saving widget
- Indexes of widgets instances starts with ‘2’ in ‘wp_options’ table
- How to update widget from widget() function?
- Add a select box to all widgets
- Separate backend “Widgets” page for each language
- How to access widget data from outside widget?
- Custom widget using get_categories select menu dropdown
- Creating a one click demo importer
- Custom widget select options needs to stay selected after save
- Why does WordPress stores widget options in a multidimensional array?
- How to save widget fields generated from an array?
- get_option returns undesired blank instance of a widget
- How to get options of all active widgets ?
- Making jQuery .change() event persistent after widget save
- Widget select option not saving
- accessing wordpress serialized data outside wp
- How to update the options table for a widget
- Widget settings disappear after refreshing page
- Use customizer or sidebar for header settings?
- Options page for widget
- Passing widget options to external script
- Widget options – where to put them?
- How to load Widget javascript + css files only if used?
- Adding iframe Content to Sidebar Widget
- Storing custom dashboard widget options in wordpress
- $post>ID displays wrong post ID
- Video Embed in Sidebar Widget with Links to Others in Category
- Shortcode from a widget is wrapped in unwanted element
- How can I whitelist only specific shortcodes for processing in text widgets?
- Bookshelf plugin and/or widget [closed]
- Create a Widget Area in the Navigation Bar for the Genesis Theme Framework?
- Manual display of widget
- Add a banner to the Dashboard
- Customized widget area – how to override or filter class xoxo?
- How to add a description to Widgets?
- add_page_menu to make shortcut to widgets
- Insert custom content before widget title/after widget opening tag
- cannot drag and drop widgets since wordpress 3.2.1
- Show widget when not using SSL
- Color Picker Showing Twice When Widget Added to Sidebar
- How can I use AJAX to save/update a widget form?
- Display assigned terms with link
- Hide all Dashboard Widgets (not remove)
- Widget modifications in a child theme
- How to get “Widget Logic” plugin’s input value in a custom widget code (to display on the Widget admin page)
- Extending WP_Widget throws error when Monster Widget used
- Making footer widgets responsive
- Custom html widget with a Joomla-style assigment
- Form link throwing website to main language
- Conditional Tags Based on Previously Viewed Posts
- Make page jumps in widget
- Query in query for Widget
- How to display first post thumbnail as a background image of a widget?
- Create widget in dashboard displaying a custom user field?
- Limit number of widgets in widget area
- How to create pagination for homepage with widgetized area?
- Hooking action once but called twice
- How to update the widget form when the image is selected?
- How can I add an author-box below a post?
- How to overload the update() of existings widgets?
- Help me out with this Undefined index ?
- Remove “Content” and “Discussion” from Right Now Dashboard Widget
- wordpress widgets screen disappeared
- Proper approach to moving complete site from one domain to another AND preserve widgets
- Why custom widget won’t appear in Block editor (Gutenberg)?
- Can the qTranslateX-Plugin translate non-article text? [closed]
- Custom widget is not appearing in the admin area
- A/B test options at the widget level [closed]
- Static image for embedded YouTube video instead of blank player?
- event organiser not loading in main content area
- How do I customize the positioning of WordPress widgets?
- Limit archive widget results
- How can I detemine the parameters needed by the_widget()?
- Fatal error: Uncaught Error: Class ‘WP_Widget’ not found
- Array showing all values of loop instead of specific value to post
- Widget not appearing in customizer
- How can I have sidebar widgets on Twenty Seventeen theme on all pages?
- Collapsible widgets [closed]
- Loop through Widgets in sidebar using widget array number?
- add image in dropdown select
- How to get widget content in WordPress based on it’s ID?
- Loading scripts only if a particular shortcode or widget is present
- Make a widget to my footer
- Always show the widget title in a wordpress widget
- Custom php Widget keeps disappearing from the front end
- Display Posts by Views (Popular Posts Widget)
- Default WordPress widgets always appear
- Add space to the end on a widget
- Insert to wp_footer if widget is found in the sidebar
- Using javascript on the new widget preview / customizer page
- Show editor widgets only on pages that use a specific template?
- Conditionally enable autoplay when using oEmbed in a custom widget
- user definable sidebar per page
- WordPress Hide Widget If $_Session Is Active?
- Post Thumbnails on Sidebar Widgets
- Using Conditional Tags to restrict something to 1 user?
- Recent posts with different class name for each post and a scrollbar?
- Classic widgets with 5.9+?
- WordPress shortcode select option not working [closed]
- Can’t edit the widgets sidebar or footer