With yoast seo plugin how to add year in title?
-
I got this code from github and its working properly, but i am using yoast seo plugin, with this plugin this code not working.
how can i add year in title with yoast seo plugin?
Also how can i add year in the_experts and open graph metatags?function wpmoly_movie_title_year( $title, $post_id ) { // Don't do this in admin if ( is_admin() ) return $title; // Apply only to movies if ( 'movie' != get_post_type( $post_id ) ) return $title; // 'the_title' filter gives a post ID, but 'single_post_title' gives a post object if ( is_object( $post_id ) ) $post_id = $post_id->ID; // Get release_date for WPMovieLibrary 2.x movies $meta = get_post_meta( get_the_ID(), '_wpmoly_movie_release_date', true ); // If release date is available if ( '' != $meta) { $date = get_post_meta( get_the_ID(), '_wpmoly_movie_release_date', true ); $date = date_i18n( 'Y', strtotime( $meta ) ); $title = $title . ' (' . $date . ')'; } return $title; } add_filter( 'the_title', 'wpmoly_movie_title_year', 10, 2 ); add_filter( 'single_post_title', 'wpmoly_movie_title_year', 10, 2 );
Viewing 11 replies - 1 through 11 (of 11 total)
Viewing 11 replies - 1 through 11 (of 11 total)
- The topic ‘With yoast seo plugin how to add year in title?’ is closed to new replies.