You can try the following code.
function custom_post_type_title ( $post_id ) {
global $wpdb;
if ( get_post_type( $post_id ) == 'cars' ) {
$engine=", ".get_post_meta($post_id, 'Engine', true).'l';
$terms = wp_get_object_terms($post_id, 'brand');
$abrand= ' '.$terms[0]->name;
$amodel=" ".$terms[1]->name;
$title = $post_id.$abrand.$amodel.$engine;
$where = array( 'ID' => $post_id );
$wpdb->update( $wpdb->posts, array( 'post_title' => $title ), $where );
}
}
add_action( 'save_post', 'custom_post_type_title' );
Related Posts:
- wp_set_object_terms creates taxonomies but does not add custom posts to it
- what is the correct way to compare dates in a WP query_posts meta_query
- don’t publish custom post type post if a meta data field isn’t valid
- How do I append multiple taxonomies to the URL?
- Creating “static” taxonomies to choose from, inside custom post type?
- Search multiple custom fields by using meta_query
- Custom Post Type – Taxonomy Dropdown Menu?
- Custom Taxonomy Template Post List with Sort Order
- Add custom field to media attachment image attribute in post editor
- Set post title from two meta fields
- How I check if the same post slug has not been used before publishing?
- How can I customize “Pages” admin (edit.php) and “Edit Page” admin (post.php) for bulk edit of custom content type?
- Using a Custom Field instead of original title field but only for Custom Post Type
- Add Taxonomy Values Within a Custom Post Type RSS Feed
- Community and User Generated Content Website: Have been thinking about Drupal but leaning on WordPress heavily
- Related links – from other sites
- Saving repeated option values in a custom query
- Assign Taxonomy Based on Custom Field Value
- How to filter out post type meta?
- Assigning the same custom meta box to multiple post types
- Dynamically add / duplicate custom meta in custom post types
- How to insert content from another Custom Post type into Post?
- Using several custom fields as custom post title
- Conditional regex in add_rewrite_rule() for specific query filters & pagination
- How to structure a site with product variations pages?
- Set a maxlength for the title input in a custom post type
- Cannot save CPT meta box
- How to display products name in a non-alphabetical order, in a custom field (taxonomy)?
- don’t publish custom post type post if a meta data field isn’t valid
- Redirect to another page using contact form 7? [closed]
- custom post data – how to
- Get Post Terms of Current Post (selected taxonomy term) – How to get only the taxonomy value and not “Array ( [0] => taxonomy term )” in the frontend?
- How to customize work area / admin area in a custom post type without plugins?
- How to display custom field value on page?
- Targeting categories in custom fields
- Display custom post type for specific user
- Need to have an archive widget which organizes and displays a custom post type using a custom date field
- How to hide a custom field from admin?
- Problems making shortcode with custom post types and taxonomy
- Query Multiple Custom Post Types & Exclude a Taxonomy Term
- Get post-meta value of all custom-posts – lowest to highest year-count?
- How to display posttypes and taxonomy in standard posts, not in a separate label?
- How to keep a record of changes to a custom field?
- Use Gravity Forms and a Shopping Cart for output to Freshbooks for an Estimate [closed]
- How do I ensure that post_type and Taxonomy use the same slug?
- Question about link two types of data in wordpress
- Custom Form / Search with Custom Post Type Data
- Adding a location field to buddypress activity
- Auto update publish date of CPT Post if default post custom field value match to cpt post CF Value
- How can i display a taxonomy? i have created a plugin and then a custom type. and a taxonomy , also i have register it
- How can I fetch all the dates from custom fields from various different custom post types and show / list them at one place in ascending order?
- Set a Default CPT taxonomy by taxonomy id
- Displaying posts inside table having issues
- Automatic Set Category For A Custom Post Type
- Convert attribute woocommerce terms (taxonomy terms) in posts of custom post type
- How to Disable option of meta field if that option is selected for any other post in custom post type?
- How to display all custom fields associated with a post type – IN THE ADMIN AREA?
- Sort by Custom Post Type (Multiple Loop)
- Query Distinct Taxonomies of Custom Post Type
- Select Menu for Custom post Type does not save
- How can i display on front page a movie that is atached in a post type
- Query multiple post of which one by taxonomy
- Exposing custom fields to the user in custom type post
- Creating post custom field text area
- Sort CPT by taxonomy AND THEN by custom field
- How to display *block number* instead *date value* on WordPress posts?
- Category display using conditions
- Where can I find the missing page sections in wordpress?
- CPT: if more than X images are in post, use pagination
- Metadata for a taxonomy – is there any WordPress way of doing this?
- Remove wrong dashes from get_the_title()
- List of Posts in a Custom Field
- How to use the Display Name as the post title in a custom post type?
- Save an array from drop-down in custom meta box
- List all images from a single post meta value
- Plugin for custom posts and fields [closed]
- Why does querying on post_tags (which has been applied to custom post types) only return posts?
- Including Custom Meta with posts_where query
- Query Multiple Taxominies Across Multiple Post type’s
- Is there a way to have the view link on manage posts page to open in a new window or tab?
- Change or update WordPress loop based on dropdown selection
- Getting rid of /my_custom_post_type/ in the single view URL
- Populate Custom Fields in a Custom Post Type?
- Custom post type menu missing after 3.0b2 -> 3.1.2 upgrade
- Custom Post Type – List all attachments on Edit Screen
- Order By Post Type ThenBy Taxonomy
- How to show CPTs in term archive
- Custom query to filter posts that have current post as a taxonomy [closed]
- WP All Import – Using Xpath to set a select value
- How to change post featured image using a custom field of category?
- How do I get array of types associated with a taxonomy?
- Publish an XML feed from a CPT with ACF fields?
- Adding dropdown select meta box to custom post type – seems restAPI is interfering
- How to create shortcode to display custom field value on a custom post type
- Group posts by custom post type
- Confusion regarding Nonce & using it in Custom Columns for Saving Checkbox Value to Post Meta
- Tag page with Custom Post Types not returning any posts
- Custom Page that comes with preloaded content for the user
- Automatically update custom field in all posts of a custom post type
- wp_set_object_terms() not adding new term to custom post and custom taxonomy