Are you using advanced custom fields, correct? Not sure if ACF will pick up the fields without the $post_id set as the second parameter for get_field, so i changed your code to include the post id.
function update_booklink_field( $post_id ) {
if ( 'book' == $_POST['post_type'] ) {
$genre = get_field('genre',$post_id);
$bookname=get_field('book name',$post_id);
$author=get_field('author',$post_id);
$booklink="http://mybooks/".$genre."https://wordpress.stackexchange.com/".$author."https://wordpress.stackexchange.com/".$bookname.".com";
update_post_meta( $post_id, 'booklink', $booklink );
}
}
add_action( 'save_post', 'update_booklink_field' );
The “save_post” action will run on publish and on post edit.
Related Posts:
- How to declare a global variable in php?
- Undefined variable in functions.php file [closed]
- load/require specific php files for specific pages/templates/post types
- Display message once per session to users with a specific role
- How to correct schedule my event weekly with wp_schedule_event()
- Execute a shortcode when clicking on a image
- get_the_content if it contains multiple lines it results in SyntaxError
- How can I add a class to a single menu item?
- WordPress returns a wrong date
- Store loop into array
- How to enlarge the media file upload size in wordpress admin
- How do I hardcode a WordPress shortcode into my theme?
- Debugging PHP object during Ajax call in WordPress
- Why is it necessary to prevent direct access to included files?
- Run a Parallel PHP Application with WordPress
- Display Post co-authored in Author Page
- Include Class File in WordPress
- How can I use a $wp_customize to edit my homepage image slider?
- Password protecting content in custom template
- How to exclude specific category from the get_the_category(); array
- WordPress override bloginfo variable
- How to Display a Single Post Excerpt
- How do I display a user’s previous orders as a select box option on a product?
- Hide wordpress field if data is empty in post!
- How to Highlight unread WordPress posts?
- Echo a hierarchical list of post data from custom fields
- ajax, right way to do it and make it works?
- How to combine wordpress_logged_in cookies in one cookie?
- Automated Cart Update With Alert Box Each Time
- Need help with Google drive API [closed]
- Is it possible to increase php memory without directives in wp-config.php, .htaccess or php.ini?
- Adding widgets to my plugin page instead of WordPress dashboard
- Problem custom control Customizer
- Running code before object-cache.php runs
- How to escape attachment image caption text?
- WordPress admin is incredibly slow [closed]
- Archive post by meta value + 24hours
- Different post styles depending on category
- Configure Php server with ISAP
- How Can I use WP_Query to Only Display 1 Post from Custom Post Type if Query Returns Posts with Matching ID in Custom Field
- Shortcode to show the code
- db converts decimal number wrong
- How to keep empty fields from appearing in php?
- Issue with php version 7.2 in running search
- Include Parent Term in wp_list_categories
- Does anyone know all parameters of get_comments()
- Can I make get_users() query global?
- Add product to cart for user – WC()->cart->add_to_cart [closed]
- preg_replace regex problem
- iframe not showing in content on blog page
- Get the name of menu item with wp_nav_menu
- What’s wrong with this piece of code? [closed]
- Where to copy woocommerce files to in my custom theme to avoid editing the core plugin?
- Twentyfifteen style author comment
- I installed WordPress locally now how do I login?
- Check in which custom taxonomy belongs and change the style
- Change out put of the_post_thumbnail in PHP
- Styling an “active” link outside of WordPress default menu
- WordPress permalink issue
- Any way to hide a blog posts text if it’s longer than let’s say 300 characters
- Show label for value only when value exists, basic php
- Counting number of posts in multiple (sub)categories using shortcode
- Display WordPress search results based on the selected Sub-Category
- how to make wordpress user submit form once?
- Update PHP version of WordPress (internal hosting)
- Where to add my PHP codes for AJAX Jquery to work?
- Display the list of user’s comments + the post title + date
- Multiple Tag Filtering
- Is it possible to change the get_posts() or wp_query() function to alter the results that are returned?
- How to optimize and reduce excessive database queries
- How to reload a php script, using AJAX and jQuery
- Notice: Undefined variable
- Make wp_editor required
- Add the shortcodes from the enfold theme to the other theme
- PHP 7.2.18 | Your PHP installation appears to be missing the MySQL extension which is required by WordPress
- I need to edit a widget, with no dashboard access
- How can i style “echo apply_filters”
- Get the total Author Favorited posts
- How to properly create multiple conditions to redirect users roles to different pages
- unable to add category in creating post dynamically
- making a search.php query
- WordPress WPDB::insert 13th param is always blank (only if format)
- Ajax not updating to database
- MySQL query in WordPress with AJAX
- enumerating custom taxonomies?
- Change colour of table td based on value
- Headers Already Sent
- Sum of Custom Meta written by Authour
- If or/and statement advanced custom fields [closed]
- Remove duplicates from foreach
- Determine if only one image attached to a post/page
- Add specific phrase after every product title including the discounted price? [closed]
- get_avatar from user id
- How do I change the Go To Categories link in the term_updated_messages
- wp_mail vs mail functions and header arrays
- WordPress get_the_term_list include class name for heirachy
- WooCommerce – Show ‘Sales’ badge on variable products where only some variations have sales price [closed]
- Add text below WooCommerce short description if metabox value is true
- ACF number less than comparison not working
- Deprecated: Return type of WC_Appointments_Availability::offsetExists($offset) [closed]