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?
- Custom Taxonomy as checkbox or dropdown
- How to set a default format for a custom post type?
- echo value from ‘select’ field type into page template using cmb2?
- Not sure why my custom post meta field isn’t saving
- How loop through posts based on custom fields
- Create a random unique 6 digit number as custom field for custom post type
- Placeholder in HTML editor text area?
- Hierarchical Custom Post Types – Show only parent on tax archive?
- wp_query check if integer exists in custom field’s array
- Visual editor issue by having multiple tiny mce editors in a CPT
- list taxonomies from a custom post type
- Meta Query Filtering not working on Custom Meta Box using Radio Buttons
- Full Custom Post Type List Organised by two Taxonomies
- Allow users to create posts without logging in?
- Include related custom fields from one post type in another post type’s JSON feed
- How can I add a custom field to an existing custom post type?
- Display Repeatable Meta Box Content
- Add tags to custom post type without menu link
- My custom taxonomy is only displaying 1 of 3 terms
- Custom Field not saving in WordPress
- How to make an API call to a custom post type but filtering by meta value?
- Migrate Custom Post Type with Custom Fields data and parent child order
- Search for custom field input of a custom post type in ajax live search
- Display Custom Field or Custom Taxonomy in front page /post/product
- Custom post type defaults to index.php for archive page
- customize Dokan multi vendor: how can i set every Dokan as child of another dokan?
- WP_Query for custom taxonomies showing posts from non-specified terms?
- Display custom tax in “while” loop
- How to delete comma from the end of results? [closed]
- Publish post and create additional posts with same content
- How do I get a nested query to only display content that the main query outputed
- How to show animal lineage/pedigree in WordPress?
- WP_Query arguments: Loop through custom post type – get all entries except excluded meta_key?
- How do i get the taxonomy term name on the CPT archive page?