Fill post titles from post content?

Hook into the_post – called when the post is actually used – and fill the title. Be aware the slug has to be changed too. If you are used not to enter a title, hook into save_post too, and let the same code do this for you. The code Download on GitHub <?php /** * … Read more

Dynamically update post title in admin page

The block editor is restoring back the title that was last saved (or typed manually into the textarea), so with the block editor, you can change the title dynamically using this code: wp.data.dispatch( ‘core/editor’ ).editPost( { title: ‘Title here’ } ) PS: You should make sure your JS file has the wp-editor, wp-edit-post or wp-data … Read more

Changing title to lowercase [closed]

Assuming this question is related to WordPress, here is answer :- You can update the titles directly into your mySQL database using simple update function. one of my user publishs all his posts uppercase (title) i want to edit them and make it normal. – Using some conditional statements as I mentioned in this code, … Read more

How to count the length of a post title?

There are actually two problems: The & is encoded as &amp;, so you have to use html_entity_decode() first. Multi-byte characters need more than one byte, and strlen() will fail with them. Don’t use strlen(). So use something like this: $title = html_entity_decode( get_the_title(), ENT_XML1, ‘UTF-8’ ); $length = mb_strlen( $title, ‘utf-8’ );

Modify page title format (when using title-tag)

If you’re using the Yoast SEO plugin (which it looks like you are) then this answer might help you If you are using yoast SEO plugin then the easiest method is to remove the archive word from “titles & metas-> Taxonomies->category” find: %%term_title%% Archives %%page%% %%sep%% %%sitename%% replace it with: %%term_title%% %%page%% %%sep%% %%sitename%% Alternatively … Read more

the_title filter applying to menu items

Use in_the_loop() conditional tag to make sure you are modifying the title inside the Loop and to prevent the hook changing titles somewhere else: function customize_wishlist_title( $title ){ $current_user = wp_get_current_user(); $loggeduser = $current_user->user_login; // give attention to the following condition: if ( is_page( 258 ) && in_the_loop() ) { $title=”<span class=”username”>”.$loggeduser.’\’s’.'</span>’.’&nbsp;’.'<span>Wishlist</span>’; } return $title; … Read more

add_theme_support( ‘title-tag’ ) in conflict with custom titles function

Your problem is that you can not use wp_title() in the theme if the theme already supports title-tag. The <head> of your theme should look like this: <head> <meta charset=”<?php bloginfo( ‘charset’ ); ?>”> <meta name=”viewport” content=”width=device-width, initial-scale=1.0″> <?php wp_head(); ?> </head> The filter and title-tag support: add_action( ‘after_setup_theme’, ‘theme_functions’ ); function theme_functions() { add_theme_support( … Read more

Bulk edit wordpress images alt and title attributes

You can use the ‘wp_get_attachment_image_attributes’ hook add_filter( ‘wp_get_attachment_image_attributes’, ‘image_attributes’, 20, 2 ); function image_attributes( $attr, $attachment ) { // Get post parent $parent = get_post_field( ‘post_parent’, $attachment ); // Get post title $title = get_post_field( ‘post_title’, $parent ); if ( is_single( $parent ) ) { $attr[‘alt’]=$title; } return $attr; } Or Check Out my new … Read more