I went through all this yesterday!
According to the codex there must be a post id given to current_user_can to check ‘edit_post’, so your capability check should be:
if( !current_user_can( 'edit_post', $post_id ) ) return;
Also, your final two lines should be more like this:
$chk = isset( $_REQUEST['page_title_off'] ) ? 'on' : 'off';
update_post_meta( $post_id, 'page_title_off', $chk );
This should turn the post meta on or off depending on whether the checkbox was ticked.
Related Posts:
- ORDER BY custom field value
- Best way to programmatically remove a category/term from a post
- display specific custom fields
- Add new “Insert Into Post” button with another function
- Multiple meta values for same meta_key adding on “Preview Changes” hit but not on saving or updating post
- Transients vs CRON +Custom Fields: Caching Data Per Post
- Create a select drop down of available menus
- Best way to allow manageable social media URLS?
- Slow meta query with multi meta keys
- Custom Field Multiple Clauses
- Adding a custom field or metabox to the post-thumbnail widget?
- Using WP Query to search by multiple meta fields
- Send Multiple Custom Field Values Through the URL
- Sort by posts that have a featured image?
- WP_Query display next custom post from today’s date
- Can ordering post list by meta_value cause performance issue?
- $wp_query meta_key naming issue [closed]
- Meta_query and numeric comparison [closed]
- Title and post URL based on custom fields?
- Woocommerce with metabox plugin
- woocommerce product custom field
- using multiple meta_key and meta_value in query_posts
- Multiple relationships in a query
- How Meta Data is different from Custom Fields of POST/PAGE in WordPress
- two custom fields question
- How to save multiple options from a dropdown in user profile
- global function to apply filter to custom field
- How to add a new meta key and assign timestamp to posts
- Display the contents of a custom field of a page on their child
- Print custom field in Query Loop block
- Read / Watch / Listen times – meta
- Login WP – Connect single field to an external api
- Is there a simpler version of WP Media?
- Order RSS content by an advanced custom field value
- Advanced search by two criteria – sort by location and date (ascending or descending)
- Collect user custom field in product page woocommerce
- Turn raw url into clickable links
- get posts where a custom field contains a text
- Displaying a custom field
- meta fields for the whole wordpress site
- Advanced Custom Fields functionality without plugin
- Get post ids sorted by meta_key
- 3.8 Media Upload and Custom Meta Box
- Displaying Custom Field Array
- Let’s Create Custom Field Template Documentation
- WordPress Settings API Repeatable fields
- WordPress creates new lines in postmeta table on post update
- How to add custom filed value after in wp post title
- User customising position of WordPress Featured Image
- Accessing Custom Fields on Pages
- How to Pass values to Custom Field through PHP in WordPress Posts?
- Custom field php
- Display a different image for each page with editor
- how to add product subscription field in woocommerce plugin
- How can I change the publish date based on a custom field?
- WP_query multiple custom fields not working
- Best way to sort estates and query them (for rent? yes/no. contains office space? yes/no)?
- Getting and calculating averge value of custom fields of the same tag
- Only admin should be able to add a particular custom field
- Automatically Add Custom Fields Value as Tags
- How to display custom fields in hestia theme
- Custom date column in user table not sorting correcting
- pass custom value from single.php to another file via get
- How to speed up post list slowed by update_meta_cache()?
- Custom Fields displaying in single line
- variable not passed correctly to database using custom field
- WordPress Blocks, setAttributes not saving
- How do i call up default post title in custom posts
- Custom Field URL + description
- How to save multiple custom user profile fields using repeater JQuery
- Query to sort a list by meta key first (if it exists), and show remaining posts without meta key ordered by title
- Issue on Creating Checkbox Field On Custom Post type
- Save input form on custom field
- Page template is missing fields or is invalid when I updating the template
- Admin – Search Events by a custom field
- create a custom field that let me include other posts
- Check if value exists before saving
- Get meta value when the page is a blog archive
- Populate a select box with data stored in the database?
- Change path to child of page when uploading image via custom field
- How can I hide my section title if there is no data in custom fields?
- wp_postmeta are updated for only one page
- Meta Box Data added to header redirect
- Upload image to wordpress
- I want to add a custom field in the rss title of each post, but don’t want it to be shown on the site
- Custom metaboxes not saving after switching themes
- added a meta box to post however when saving menu while debug on throws a warning
- How can i get the actor birthday by date?
- Post rating using Custom Field
- Inserting custom fields into new-post.php without using the Custom Fields Template plugin?
- woocommerce how in checkout to add my custom field check box, and when i check it hide the shipping adress and add tax 19% [closed]
- How can I attach files without using a plugin?
- Advanced Custom Fields for Header that are Editable from a Page [closed]
- Change Fields of Comments and make them searchable?
- Shortcode not picking up custom field
- Order by a meta field in query loop
- Add CSS class to posts with certain meta key
- Match submitted array fields with the MYSQL database fields to update them correctly in PHP
- Best way for managing images of ads banners
- Crop custom image size vs actual size