Adding schema.org itemprop to WP4.1 Title Tag

If your theme is using add_theme_support(‘title-tag’), then you can try the following: remove_action( ‘wp_head’, ‘_wp_render_title_tag’, 1 ); and then just hook in your own modified version: add_action( ‘wp_head’, ‘wpse_render_title_tag_with_itemprop’, 1 ); function wpse_render_title_tag_with_itemprop() { if ( did_action( ‘wp_head’ ) || doing_action( ‘wp_head’ ) ) { printf( ‘<title itemprop=”name”>%s</title>’ . PHP_EOL, wp_title( ‘|’, false, ‘right’ ) ); … Read more

Page title not showing up

to show the page title for the page set as the ‘blog’ or ‘posts page’, you need to add some code, maybe via a filter on wp_title(); example: add_filter( ‘wp_title’, ‘wpse_174379_show_posts_page_wp_title’ ); function wpse_174379_show_posts_page_wp_title( $title ) { if( get_option( ‘page_for_posts’ ) ) { $posts_page = get_post( get_option( ‘page_for_posts’) ); $title=” ” . $posts_page->post_title . ‘ … Read more

How to echo a different title to the page if it’s opened on an android mobile phone

I’m not sure where this php_browser_info() function comes from. You can try the following instead: /** * Modify the front/home page title for Android devices */ add_filter( ‘wp_title’, function( $title ) { return ( is_front_page() || is_home() ) && isset( $_SERVER[‘HTTP_USER_AGENT’] ) && false !== stripos( $_SERVER[‘HTTP_USER_AGENT’], ‘android’ ) ? ‘Test Android’ : $title; }, PHP_INT_MAX … Read more

Variables in post title

Just use the the_title filter to hook into the title content and work with that. add_filter( ‘the_title’, function( $title ) { // Manipulate the $title as you want and then return that. // You can add test conditions such as ‘is_main_query’ // (https://codex.wordpress.org/Function_Reference/is_main_query) return $title; } );

Set post title based on first h2 element in the content section

If you can handle this in the PHP side, you might be able to pull the h2 tags from the content using regular expression. PHP VERSION Test content $content = “<h2>This is H2 Content</h2><p>This is p content</p>Random Content<h2>This is another H2 section</h2><b><h2>This the third H2 section</h2></b>”; Grab any text inside H2s preg_match_all(‘#<h2>(.*?)</h2>#’, $content, $matches); // … Read more

Add anchor text to php

You can use the_title filter. Just remember to remove it after wp_list_pages() otherwise it will effect everywhere on the site like in menu, main title, search results etc. Example:- add_filter(‘the_title’, ‘my_custom_title’); wp_list_pages(); remove_filter(‘the_title’, ‘my_custom_title’); function my_custom_title($current_title) { if ($current_title == ‘blue’) { $current_title = $current_title . ‘ widget’; } return $current_title; }

How to prevent WordPress from updating the modified time?

The question of how to customize which post data gets updated has been answered elsewhere on StackExchange. Here is a specific example of how to stop the modified date from being updated: function stop_modified_date_update( $new, $old ) { $new[‘post_modified’] = $old[‘post_modified’]; $new[‘post_modified_gmt’] = $old[‘post_modified_gmt’]; return $new; } add_filter( ‘wp_insert_post_data’, ‘stop_modified_date_update’, 10, 2 ); // do … Read more

Uppercase to sentence case for post titles

You can do that with a command in your database: UPDATE `wp_posts` /* Adjust the prefix! */ SET `post_title` = CONCAT( UCASE( /* First letter uppercase */ SUBSTRING( `post_title`, 1, 1 ) ), ”, LCASE( /* The rest in lowercase */ SUBSTRING( `post_title`, 2, LENGTH(`post_title`) ) ) ); If your author has a habit of … Read more

Locating Global Variables

Child themes The WordPress Way of modifying the theme’s page-templates/front-page.php is to create a child theme, then duplicate this file in the child theme and make the modifications there. Your modified template file will be loaded instead of the parent theme’s file. This allows the parent theme to be updated without losing the modifications made … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)