Using a Custom Field instead of original title field but only for Custom Post Type

The solution you are working on will always represent multiple database inserts as the post will be saved and then the the title re-saved in a second database write. That is the nature of the save_post hook, since it runs after the primary post save. Additionally, the code you found is wildly overcomplicated. Interestingly, the … Read more

How to update a custom post title from a front-end form using ACF fields?

You check if !$value before assigning the title from the fields, that test will be false once the post has a title. If you always want it to update, then remove the test. function auto_title_insert() { return $_POST[‘fields’][‘field_538626f57e84c’].’ ‘.$_POST[‘fields’][‘field_538627ffeccb0′].’ ‘.$_POST[‘fields’][‘field_53863a5c7502b’].’ ‘.$_POST[‘fields’][‘fields[field_53a9bb09f82ba]’]; } add_filter( ‘title_save_pre’, ‘auto_title_insert’ );

Include category title in wp_title

Create a helper function to get all parent categories (each post can be in multiple categories): function parent_cat_names( $sep = ‘|’ ) { if ( ! is_single() or array() === $categories = get_the_category() ) return ”; $parents = array (); foreach ( $categories as $category ) { $parent = end( get_ancestors( $category->term_id, ‘category’ ) ); … Read more

Can’t change the title tag with wp_title filter

When adding title-tag support in a theme, the title tag can be filtered by several filters, but not wp_title. The reason is that if the theme supports title-tag, WordPress uses wp_get_document_title() instead of wp_title(). For themes with support for title-tag you can use document_title_parts: add_filter( ‘document_title_parts’, ‘filter_document_title_parts’ ); function filter_document_title_parts( $title_parts ) { $title_parts[‘title’] = … Read more

Blank on static home page?

From the Codex If you are using a custom homepage with custom loops and stuff or a custom front-page, you will have an empty wp_title. Here goes a neat hack to add the description/tagline at the wp_title place on homepage: add_filter( ‘wp_title’, ‘baw_hack_wp_title_for_home’ ); function baw_hack_wp_title_for_home( $title ) { if( empty( $title ) && ( … Read more

Change Default Custom Fields Metabox Name

You need to declare the $wp_meta_boxes array as global: global $wp_meta_boxes; If it still doesn’t work try: add_filter(‘add_meta_boxes’, ‘change_meta_box_titles’); function change_meta_box_titles() { global $wp_meta_boxes; echo ‘<pre>’; print_r($wp_meta_boxes); echo ‘</pre>’; } to see what’s going on (and to check where the title is). You should also prefix your function names to prevent a clash with WP … Read more