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

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

How do I edit the tag without using the deprecated `wp_title()` function?

It looks like _wp_render_title_tag() method is what outputs the tag, and the source code in 4.8 is available here: https://core.trac.wordpress.org/browser/tags/4.8/src/wp-includes/general-template.php#L1083 You can see: echo ‘<title>’ . wp_get_document_title() . ‘</title>’ . “\n”; You could first remove the action from wp_head: remove_action( ‘wp_head’, ‘_wp_render_title_tag’, 1 ); Then add your own title render method: add_action( ‘wp_head’, ‘_wp_render_title_tag_itemprop’, 1 … Read more

How to make a H1 different then the Title?

Yes! Custom fields: http://codex.wordpress.org/Custom_Fields You can create alternate post titles via the post editor, and then you can display them with some minor adjustments to the single.php and index.php templates (or {$post_type}-archive.php templates, if you have them). For example: <?php $post_title = get_post_meta($post->ID, ‘Post-Title’, true); //”Post-Title” or whatever you call your custom field if ($post_title) … Read more

WordPress i18n-friendly preg_replace post title

We can use the protected_title_format and private_title_format filters, available since WordPress version 2.8: add_filter( ‘protected_title_format’, ‘wpse_pure_title’, 10, 2 ); add_filter( ‘private_title_format’, ‘wpse_pure_title’, 10, 2 ); function wpse_pure_title( $format, \WP_Post $post ) { return ‘mycpt’ === get_post_type( $post ) ? ‘%s’ : $format; } to get rid of the “Private:” and “Protected:” parts on the front-end … Read more

Changing “Enter title here” based on post format

You need to do the following; jQuery(document).ready(function( $ ) { $(‘input.post-format’).click(function(){ $(‘#title-prompt-text’).val( $(this).next(‘label’).text()); }) }); This will replace the title with whichever post format you select. Save the above into a file called custom-post-title.js and you will need to place this file into your theme folder. Either in the root or within a folder named … Read more

REQUIRED: The theme must not used the tags. | REQUIRED: The theme must not call to wp_title()

WordPress added support for the title-tag feature in version 4.1 and it’s now a required feature for themes uploaded to the repo. To implement this feature, make sure your theme does not have the title tag hard coded within header.php, e.g.: <title><?php wp_title( ‘|’, true, ‘right’ ); ?></title> Configure your theme with title-tag support like … Read more