Last active
March 20, 2018 15:54
-
-
Save davecurrierseo/371a51d754cf1a272738ad642eb70d8e to your computer and use it in GitHub Desktop.
Get Yoast Meta Description On Page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Automatically Reduce Character Count on Titles | |
function filter_wpseo_title( $wpseo_replace_vars ) { | |
$sitename = get_bloginfo('name'); | |
$new_title = get_the_title(); | |
$fullTitle = $new_title . ' | ' . $sitename; | |
if ( (is_single() || is_archive() || is_page()) && ($fullTitle == $wpseo_replace_vars) && (strlen($fullTitle) >= 65)) { | |
return $new_title; | |
} else { | |
return $wpseo_replace_vars; | |
} | |
}; | |
add_filter( 'wpseo_title', 'filter_wpseo_title', 10, 2 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php echo get_post_meta($post->ID, '_yoast_wpseo_metadesc', true); ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php echo get_post_meta($post->ID, '_yoast_wpseo_title', true); ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Adds noindex, follow to pagination | |
add_action( 'wp_head', 'add_noindex' ); | |
function add_noindex() { | |
if(is_paged()) { | |
echo '<meta name="robots" content="noindex,follow" />'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment