Directly accessing PHP files is not really how WordPress works.
You currently have your code in a random PHP file that has no connection to WordPress. It’s probably throwing a Fatal error (Call to undefined function), which is why the next line doesn’t get executed.
You said this code is in your theme, so I would start by putting that code in functions.php
. If you want it in a different file, you’ll need to add this to that functions.php
file:
require_once '_options.php';
Or if it’s in a folder in your theme (like “includes”), you’d do:
require_once 'includes/_options.php';
To control when that code is fired, you would use one of the many WordPress hooks.
For the correct way you create an options page, check out this article in the codex.
Related Posts:
- Check if Post Title exists, Insert post if doesn’t, Add Incremental # to Meta if does
- post formats – how to switch meta boxes when changing format?
- Execute action after post is saved with all related post_meta records (data)
- How get post id from meta value
- Safe to delete blank postmeta?
- How to update/insert custom field(post meta) data with wordpress REST API?
- get_post_meta returning empty string when data shows in the database
- publish_post action hook doesn’t give post_meta_data
- How to access the post meta of a post that has just been published?
- How to get all term meta for a taxonomy – getting term_meta for taxonomy
- Should I sanitize custom post meta if it is going to be escaped later?
- Query between two meta values?
- How to get meta value in wp_attachment_metadata
- Clean up output added via wp_head()
- List posts under meta_value heading
- loop through all meta keys with get_post_meta
- WP_POSTMETA changes site crash
- meta_post_meta return value 1
- Saving html into postmeta without stripping tags – safe?
- How to show Published date and/or Modified date
- wp_update_user isn’t instantly?
- INSERT ON DUPLICATE KEY UPDATE failes in postmeta table
- Set Checkbox as checked by default
- running function during post save and adding variable to post meta
- replacing the_autor or make callback
- Some post meta fields stop saving after a few successful saves
- Save an array of values in the post meta box
- Custom post meta values reset by autosave [duplicate]
- Compare meta_query with a Regular Expression and do a less-than operation on it
- get_post_meta() empty in preview WHEN custom post is published [closed]
- Add Embed.ly API objects to post_meta on update
- Editing does not change post_name
- Compare string with post id in wpdb and do stuff when match is found
- $wpdb class updating meta_value using Ajax [closed]
- cleaning up safely wordpress wp_postmeta table
- How to selected which tags to print, instead of printing the whole tag list?
- Why does get_transient() always return string even if integer set?
- Author_meta ONLY if it exists
- query posts and split meta information into separate div’s
- How to test the outcome of a wpdb query?
- add unique string as custom-field to every post
- How do I insert a new meta key / value pair, but only if another meta key is present?
- “Cannot use import statement outside a module” JS error while adding a custom meta block?
- Gutenberg featured image checkbox – checkbox not correctly set on editing page reload
- How to properly use oneOf and anyOf in Rest Schema?
- Get the author meta adds now
- wordpress is_front_page() issue
- show ad after # paragraphs
- If ACF meta_key has meta_value
- update_post_meta not working?
- How we can get “get_post_meta” of specific user who added it
- Change wordpress meta tag description using WP functions
- Repeated nav bar queries failing to be cached
- Randomizing Post Links Outside of Loop – No Author or Date
- help to decipher wp metadata
- Cant create or update meta fields using WordPress REST API
- Filter posts by meta key
- Display current ranking of post as a number in post title
- Insert Custom Field Value
- delete duplicates wp_postmeta
- SQL query – get a featured image’s alt / alternative text
- I can not display meta value in extras.php and template-tags.php
- update_post_meta() updating nested array in Multidimensional array with empty sub-array
- Post Thumbnail missing when using webp format while sharing
- How do I list taxonomies that have upcoming events in WP? Is there a way to do this without having to query posts first?
- Sorting my posts on homepage my specific value in post_meta table
- Bulk Update Post Meta Values from Different Post via Rest Api
- Strict comparisons problem when using boolean post meta
- Why is the actual number of thumbnail images not matching what is store in an attachments metadata?
- How to register post meta with multi level arrays?
- Check if any meta on the post has value then display content
- If I disable screen options, does WP still try to update post meta?
- Combine meta query and give a specific meta query a higher priority
- Can we have duplicate key pair values in post meta data?
- Meta data being pulled from wp-login.php
- Get table parameter and save in meta value
- How can i show post views using specified post ID?
- How to add/update post meta to use in query?
- gettext localization is not working
- Move Entry Meta Above Title in Archives (Genesis + Brunch Pro)
- Update Post metafield of specific categories
- Using Self Hosted Video URL With Custom Fields
- Exclude category from DB query
- How to sort by meta value num, but ignore zero value?
- Create a Gallery and update Post Parent of Attachment Images
- Update event post meta each day automaticaly
- Problem serializing single quote and double quote into post meta
- Storing post_meta fields in array
- Advanced Custom Field — grabbing post_meta from previous post
- Fetching array of postmeta with $wpdb and in_array conditional
- Piklist File Upload
- update_post_meta() not working in bulk option
- How to update the ‘modified_time’ of a post ONLY when content is changed?
- How to create a link for wordpress meta datas?
- Fetch post meta data on POST request
- Which query method to use? (edit- wpdb syntax problems)
- How to update post meta with xml data
- get_children filter with postmeta
- wp_postmeta store multiple values in one key [closed]
- How we insert values into database using metabox WordPress?