Skip to content

Instantly share code, notes, and snippets.

@oldlastman
Last active November 9, 2021 20:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oldlastman/e7eab1f1ca186f90ecc7bc672a251d2f to your computer and use it in GitHub Desktop.
Save oldlastman/e7eab1f1ca186f90ecc7bc672a251d2f to your computer and use it in GitHub Desktop.
yoast seo description shortcode
<?php
/*si se va a usar como plugin en solitario añadir la información de plugin*/
/* utilizar la meta description para mostrarlo en web*/
function att_yoast_metadescription_sc() {
$metadescription = get_post_meta(get_the_ID(), '_yoast_wpseo_metadesc', true);
// en caso de no exister descripción devolver mensaje en blanco
if (!$metadescription) {
$metadescription = '';
}
return $metadescription;
}
add_shortcode( 'att_yoast_metadescription', 'att_yoast_metadescription_sc' );
/*quitar último elemento de breadcrum si es un paginado*/
function att_remove_yoast_breadcrumb_link($link_output , $link)
{
$text_array = explode(' ', $link['text']);
if ( ( ($text_array[0]=='Página')||($text_array[0]=='Page')) && ( is_numeric($text_array[1]) ) ) {
$link_output = '';
}
return $link_output;
}
add_filter('wpseo_breadcrumb_single_link' ,'att_remove_yoast_breadcrumb_link', 10 ,2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment