Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

Save the value of a wp_dropdown_pages

For the second part of your question: in your args variable, you can set the selected argument to whatever is saved in your database. See the codex for more details here.

I’m currently working on the same issue, I’ll update and clarify once I figure everything out out.

EDIT : Okay! I DID IT.

Here’s my save function:

function my_custom_meta_save( $post_id ) {

// Checks save status
$is_autosave = wp_is_post_autosave( $post_id );
$is_revision = wp_is_post_revision( $post_id );
$is_valid_nonce = ( isset( $_POST[ 'my_custom_nonce' ] ) && wp_verify_nonce( $_POST[ 'my_custom_nonce' ], basename( __FILE__ ) ) ) ? 'true' : 'false';

// Exits script depending on save status
if ($is_autosave || $is_revision || !$is_valid_nonce ) {
    return;
}


// Checks for input and sanitizes/saves if needed
if ( isset( $_POST[ 'meta_key' ] ) ) {
    update_post_meta( $post_id, 'meta_key', $_POST[ 'meta_key' ] );
}

}
add_action( 'save_post', 'my_custom_meta_save' )

Annnnd here’s my callback function:

function my_custom_meta_callback() {
// Get the stored value from the database
global $post;
$meta = get_post_meta( $post->ID, 'sos_internal_gallery', true);

// TO DO: Exclude galleries that are already being displayed elsewhere
$args = array(
    'echo'                  => true,
    'name'                  => 'sos_internal_gallery',
    'id'                    => 'sos_internal_gallery',
    'show_option_none'      => 'Select a slider',
    'post_type'             => 'sosslider',
    'sort_column'           => 'post_title',
    'selected'              => $meta
);

// Create drop down that lists all published sliders
wp_dropdown_pages( $args );
}

Hope this helps! It only took me all day to figure out.

Related Posts:

  1. How to update custom fields using the wp_insert_post() function?
  2. Get meta_id along with meta_key and meta_value
  3. How can merge two arrays values in one array and save in database
  4. Check if user already visited this post today
  5. Display all meta for a post?
  6. Drop down+sort blog posts date added/most popular
  7. How to display multiple Post meta_key/meta_values by SQL query
  8. the_post_thumbnail() based on the Post ID
  9. How to use multiple query with same meta key
  10. How to update single value in multi dimensional Post Meta?
  11. Save selected item from dropdown menu in a meta box as a metadata value for a custom post type
  12. How do I create a drop down menu in a widget?
  13. Second select list values are not saved after clicking update
  14. Why is my get_post_meta always empty
  15. Compare two meta key values against each other inside the get_posts array?
  16. How can update custom meta for all posts
  17. Replacing the NavWalker dropdown element
  18. Select dropdown not showing selected value php
  19. Use ajax to update_post_meta
  20. Archive dropdown styling not applied
  21. Getting the dropdown menu to redirect to different pages?
  22. how to increase custom post value by one most efficiently?
  23. Batch update a post meta field value of each post in Post Type
  24. How to Display Image Meta underneath EVERY image in EVERY post
  25. Change description on specific WooCommerce product status change
  26. Use WP_Query in shortcode
  27. Get Current User Id Inside a Loop Returns 0 For a Shortcode
  28. Random order of WP_Query results with highest meta value
  29. How to make drop down post title
  30. The text box have space character
  31. how to remove metadata from the posts of my blog?
  32. How can I create a list of page titles from custom meta values?
  33. Trying to remove post thumbnail with plugin
  34. Randomly Assign an Image’s Alt Text Based on Data From Post
  35. Advanced Meta Query for Large Calendar Website (12k+ posts) (175k+ wp_postmeta rows)
  36. Filter Select results based on selection
  37. Sort custom meta column by other meta value
  38. Store multiple custom field as post meta per post(css, js, html, 2 link) [closed]
  39. How to VAR_DUMP a $variable during checkout process (Is my product meta callable?)
  40. Creating user status mode in WordPress
  41. How to pick the default selected value in wordpress dropdown?
  42. Need help with Google drive API [closed]
  43. how to save selected option in variable for rest api category filter
  44. Archive post by meta value + 24hours
  45. Display parent and child taxonomies in separate drop down select fields
  46. WordPress update_post_meta updating with empty meta_value field [closed]
  47. wp_dropdown_pages auto submit
  48. Is it possible to retrieve all posts with a certain value for metadata?
  49. Get post id within comments loop
  50. Non-Closing PHP Query in WordPress Loop
  51. Querying Database with wpdb
  52. update_post_meta only updating on last loop of foreach
  53. Isotope Drop Down Categories Filter Function
  54. how to get serialized post meta
  55. How to use two meta_compare in an array?
  56. Remove empty terms from array, sort alphabetically, update back to repeating field
  57. WordPress loop by meta key that is an array? and how loop multiple arrays
  58. WordPress yoast seo plugin – parse snippet var in meta description
  59. HTML dropdown setting not showing last saved value in the database
  60. Sorting dynamic select/dropdown for Contact Form 7 of Modern Tribe Events posts
  61. How to store multiple custom meta box
  62. How to add post meta in while loop?
  63. Add category to post meta
  64. Using rules in Posts
  65. How to use wp_nav_menu to create custom dropdown menu?
  66. Update post meta – Custom field does not match meta-key
  67. Order a WP_Query by meta value where the value is an array
  68. Add a custom class to the body tag using custom fields
  69. Define category ID using get_post_meta
  70. Custom Taxonomy Select Menu: Setting default option value?
  71. Unable to Call More than One Meta Box Output
  72. Hide a div when a custom field is empty
  73. Update value of a associative array with update_post_meta
  74. Front end file upload returning wrong attachment url
  75. Post meta select input, if statement
  76. go to home page when i select default in select-box
  77. WordPress stripping out custom field tags
  78. How to set value selected using select2 jquery plugin
  79. Efficient way of querying for a “fallback” post?
  80. WordPress AJAX load post metadata in modal
  81. dropdown with no submit
  82. get_post_meta with variable
  83. Post from front end form to post_meta
  84. Order by in foreach
  85. custom field meta-box with dropdown/autocomplete
  86. Page 2+ of taxonomy archives does not recognise sort-order from dropdown
  87. Save data of select list after clicking save
  88. retrieve wordpress post-meta using php not wordpress functions
  89. Postmeta not saving
  90. If custom field doesn’t exist, or exists and it’s true show title?
  91. get_post_meta is always empty when I use wp_mail
  92. get_post_meta no longer working
  93. Dropdown Menu for Query_Posts
  94. How to add together (get the sum) a field from all author’s posts
  95. Metadata on the WP_Post object
  96. How to display the date under the post title?
  97. Open WordPress Page from selected option dropdown
  98. Contact form with dynamic dropdown and filter
  99. How do I get a function to work in single.php
  100. How to modify default tags in wp_head()
Categories PHP Tags dropdown, php, post-meta
Load different single.php templates according to post layout selection
Bar graphs with dynamic data

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress