<?php selected() ?>
compares the value of the stored data and which option should appear first, my error was that I wasn’t storing the variable to compare it to correctly.
$selected = isset( $values['location'] ) ? esc_attr( $values['location'][0] ) : ”;
should be changed to:
$selected = isset( $custom['location'] ) ? esc_attr( $custom['location'][0] ) : ”;
It was a simple syntax error on my part, as I was referring to the variable incorrectly. Once that was changed, the function <?php selected( $selected, 'Option 1' ); ?>
will compare the variable vs. the string in place and then display selected="selected"
to place that drop-down item on top.
Related Posts:
- Auto close (hide) custom metabox / set default state
- How to activate “Description” metabox for menu item programmatically?
- radio button is checked but display not check
- How to hide, and not to remove the attributes metabox?
- get_post_type() in in_array doesn’t work for some reason
- How to hide a plugin metabox for non admins when a user adds a new post
- Custom Attachment Caption Fields
- Adding jQuery datepicker to Custom Post Type Metabox [closed]
- Use a shortcode to display custom meta box contents
- How to change a meta value (of a published post) after X days.?
- sort metabox columns in listing Single
- How to avoid saving empty data to sql while using add_meta_box
- Save Meta when custom Taxonomy Saves
- Render metabox gallery in frontend
- Creating a “Related Meta” type field?
- Meta Box value not been pulled in
- Decimal stripped from metabox number
- How to check if a user exists by a given id
- How to use the do_action () with parameter
- TinyMCE custom styles remove class when switching styles
- Extending the site search to include a single custom field
- Notify users whenever a new post is published based on their preference
- Show/hide Widgets in Dashboard Based on Current Advanced Custom Fields Option
- syntax for remove_filter in parent theme with class
- How to remove a metabox from menu editor page?
- Remove Header and Footer in iframe
- How to Acheive the custom woocommerce category template
- Can I remove the Rich Text box editor for a specific post?
- Formatting post content to exclude gallery
- WordPress – thumbnail image from youtube (function and loop)
- Problem with extract() with custom shortcode
- CSS stylesheet not loading
- How To Get WordPress Categories Link List?
- Generate permalinks
- Best Practice for Syncing Local Development With Staging Development [closed]
- How can I create a page with a specific URL?
- When using wp_enqueue_script(); in a theme why don’t we use add_action?
- Multiple CSS body classes to specific page I.D.’s – is this possible?
- wp_validate_logged_in_cookie
- How does this function get the id of the most recent post?
- Batch update menu_order attribute alphabetically
- How to create function from code?
- Simple custom theme option not being saved
- Automatically wrap multiple images in div
- Ajax not working properly
- create shortcode to list users with specific meta key value
- How to add ‘data-caption’ inside an anchor tag
- How can I get my Script to work on the Login page?
- Search filter by Post title OR Meta Title Value [duplicate]
- Why is functions.php file in child not initializing and over-writing parent?
- WordPress metaboxes – textfield suggestion automatically populated
- Filtering out the #more anchor link that gets produced by
- file_get_contents – failed to open stream
- Exclude from the query posts with meta_key and meta_value
- wp_nonce_field is breaking form for reasons unknown
- How do I call a function to use on a page?
- Different favicon on different pages
- Javascript not loading after the document ready
- Need to convert image url to a Base_64 data url with wordpress function..
- Add Adsense code between job listings – wp job manager plugin
- How do I display a date correctly that is stored in the database as a backwards 8 digit number from Advanced Custom Fields? [closed]
- Modify shortcode to work with custom post types
- How to hightlight all ancestor menu items of a child page NOT displayed in menu
- dynamic enquiry form [closed]
- Fatal error: allowed memory size when after using enqueue_script
- How would I make a function to dynamically determine if user is logged to change navigation menu text?
- How to apply the ‘current_page_item’ class to an archive page in `wp_list_pages()`?
- How to redirect Subscribers on login to specific page, when logging in from a Page
- how can I add filter in specfic field in my website?
- Which filter fires upon setting a featured image
- functions.php pharse error on complete new install
- If has action not working as expected
- Update wp_postmeta table based on 2 keys
- Best practice to call a function from a button-link?
- Disable wordpress update notification
- How to customize archive widget only for cpt?
- Shortcode to output category description by passing ID
- some profile informations like youtube link doesnt seem
- Help using ShortCodes to style whole chunks of the post
- How to modify or override a core function (wp_star_rating)
- Is there is a way to check daily first login?
- Filter posts on new page
- Sticky – Featured Image
- delete_user_meta for user in spesific group
- Pagination not working on my archive page for a custom post type
- WordPress Jquery+scripts enqueue issue
- Remove Featured Images from Posts Older Than a Certain Date
- Adding a jQuery rotator function
- How to pass a variable from a template page to the child theme functions.php
- Home/Static Page View for Visitors pages after that should be restricted
- functions.php filters not applied in AJAX call
- Settings in functions.php used by a plugin
- Make WordPress search for only this tags or exclude certain tags from search [duplicate]
- Adding result from PHP function into an input field
- Using array page name together with page id to deregister script
- Echo a div to header.php from functions.php
- Modifying Page-Links format
- how to handle multiple forloop?
- PHP error in shortcode [closed]
- How to get variable from other function inside class function using add_action for Ajax call