For gain result custom post titles read-only for all users except the admin, you can use the edit_post
capability along with the admin_init
hook.
add_action('admin_init', 'restrict_custom_post_title_editing');
function restrict_custom_post_title_editing() {
// Check if the current user is not an admin
if (!current_user_can('administrator')) {
// Get the post types for which you want to restrict title editing
$restricted_post_types = array('your_custom_post_type_slug_here');
// Loop through each restricted post type
foreach ($restricted_post_types as $post_type) {
// Remove the capability to edit the post title
remove_post_type_support($post_type, 'title');
}
}
}
Related Posts:
- Custom post type for ‘staff’ versus using wordpress user profiles?
- What are the differences between custom post type and custom page templates?
- How to get custom post type label and singular label from its slug?
- next_post_link() not working for single custom post type post
- How to set a default format for a custom post type?
- Now can I group custom post types together?
- Does anyone have any frameworks to setup custom post types and related actions/filters?
- Exclude add_filter from the admin
- Undefined property: stdClass::$labels in general-template.php post_type_archive_title()
- Sanitizing post content for use in an email
- Genesis Child and Custom Post Type
- Query multiple taxonomy in Custom Post Type
- automatically create taxonomy with same name as post title
- saving custom post type data to different table in wordpress
- Display “Post 2 of 4” on single post page?
- Create Custom Post Type Archive Page with Sub Categories Navigation Sidebar
- register_post_type – rewrite / feeds, what’s it for?
- WordPress import not importing custom taxonomy
- Why are navigation items saved in the database?
- Filter posts with meta_query NOT IN where value has multiple values
- How to make post sticky in the admin page?
- WP 4.7 broke get_post_type or requires an explicit integer value?
- Remove base slug in permalinks of hierarchical custom post type
- How to show the archive / post type description on Single templates
- is_main_query() not working for WP REST API
- How can I move a custom taxonomy and its data from one post type to another?
- rewrite custom post type slug in wp admin
- Displaying the type of post (Custom) in a single.php
- Show listings from Impress Listing plugin in random order using taxonomy and terms
- Get next and previous 3 posts in a term in single post page
- Can’t edit custom post type
- redirecting improperly after updating custom taxonomy term when referring from CPT edit page
- Deleting Custom Posts & Meta Data on Uninstall
- I’d like to cycle through existing posts in a post type, showing one per day ordered by title, and starting over when the last is reached
- Options page – dropdown of users
- Addition of custom option panel crashes Media Library & Admin Area
- CPT’s with landing page instead of archive – Url Rewrite?
- How to produce a sub-page-system in WordPress
- Remove “show sharing buttons” metabox Jetpack from custom post type
- How can I add a filter to a particular post format?
- Custom post type causes php-error in php version 5.2.17
- How do you make a custom post type items automatically delete items 3 months after publication?
- Custom Post Type Metadata Not Saving
- get_post_meta is not working inside shortcode
- False Positive on has_post_thumbnail
- Custom Taxonomy not displaying all post
- Custom Meta Box Causing Error: “Are you sure you want to do this? Please try again.”
- Iterating through Object Array to customise display of full custom taxonomy for custom post type
- When updating non-public custom post type it says “Post updated. View Post”
- When I choose category from dropdown then everything working fine.But in backend it checked only child not parent [closed]
- Keep getting logged out
- Enable comments on custom page type – option not showing in “customize” for theme
- How to migrate Custom Field Template to a WordPress Multisite
- How to Query in WordPress which shows Alphabetic Posts?
- Using breadcrumb to return from single-page to list
- How can I lock specific posts (cpt’s) from editing by anyone other than ADMINS
- Why do I need to register my custom post type a second time when flushing rewrite rules?
- How do I Query 2 Custom Post Types?
- Function to erase every post from a taxonomy
- Custom Post Type or Shortcode, What to choose? [closed]
- Building a Data Intensive Website with WordPress
- Custom post type, taxonomy and admin bar
- Change permalink for custom post type?
- Use Author Ids or Names to echo different output inside loop
- Truncate custom post type content
- Add parameters to Yoast SEO plugin schema in functions.php [closed]
- Use a different URL path / permalink for CPT
- Group episodes by seasons
- allowing custom user role to access custom post type in wordpress admin
- Why this didn’t work if i use get_the_ID(), but works if i pass the numeric id
- Create API’s for custom-post types & custom queries using REST or Graphql
- click tags for custom post types
- Author page not loading the authored post archives
- How can i remove post type archive URL?
- Delete all custom posts then upload a new CSV of events
- Custom post type URL structure with site.com/custom_taxonomy_slug/post_name
- My CPT has archive false, now I need use parent Page for slug
- Custom taxonomy archive slug overwrites static page
- Slugs on hierarchical taxonomies
- Links Image in “Catalog” Page to Posts
- ACF saving posts
- what file is required to be created in plugin folder in order to show all the post content of a CPT with the help of permalink
- All custom posts are not showing up
- WordPress query posts by custom post type not workng
- How can draft post after 1 year
- Menu disappears with custom post type link
- Structuring 3K pages in WordPress
- Fetch posts list from fist CPT taxonomy term and list under 2. CPT
- shortcode order for event custom post type
- How can I detect a chosen Isotope layout option from within Javascript to generate appropriate layout?
- How can i embbed two different galleries in custom post type
- How to query the content of a specific custom post type?
- No Current Class showing in Menu for Custom Post Types
- create functions based on array values
- Split custom post list into two columns
- How can i display on front page a movie that is atached in a post type
- WordPress pagination URL
- how to implement club post type
- Get only one custom post from each category
- Show content from pages based on Current Date