karmelooo
Forum Replies Created
-
Forum: Plugins
In reply to: [Yoast SEO] Yoast Seo breadcrumbs – How to add text to before categorry/tagsMy solution that works ??
add_filter(‘wpseo_breadcrumb_single_link’, ‘filter_breadcrumbs_for_h1’, 10, 2);
function filter_breadcrumbs_for_h1($link_output, $link) {if ( is_category() ) {
$link_output = preg_replace(“/<span\s(.+?)>(.+?)<\/span>/is”, “<span $1>Category: ”$2”</span>”, $link_output);
return $link_output;
}else if ( is_tag() ) {
$link_output = preg_replace(“/<span\s(.+?)>(.+?)<\/span>/is”, “<span $1>Tag: ”$2”</span>”, $link_output);
return $link_output;
}else {
$link_output = preg_replace(“/<span\s(.+?)>(.+?)<\/span>/is”, “<span $1>$2</span>”, $link_output);
return $link_output;
}}
- This reply was modified 4 years, 5 months ago by karmelooo.
Forum: Plugins
In reply to: [Yoast SEO] Yoast Seo breadcrumbs – How to add text to before categorry/tagsI found something like this, but I have no idea how to add a category and tags there. I can add a category url, but I want a text in front of each category and tag.
<?php /********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/ /* * Add a link to the Yoast SEO breadcrumbs * Credit: https://wordpress.stackexchange.com/users/8495/rjb * Last Tested: Nov 30 2018 using Yoast SEO 9.2 on WordPress 4.9.8 ********* * DIFFERENT POST TYPES * Post: Change 123456 to the post ID * Page: Change is_single to is_page and 123456 to the page ID * Custom Post Type: Change is_single to is_singular and 123456 to the 'post_type_slug' Example: is_singular( 'cpt_slug' ) ********* * MULTIPLE ITEMS * Multiple of the same type can use an array. Example: is_single( array( 123456, 234567, 345678 ) ) * Multiple of different types can repeat the if statement */ add_filter( 'wpseo_breadcrumb_links', 'yoast_seo_breadcrumb_append_link' ); function yoast_seo_breadcrumb_append_link( $links ) { global $post; if ( is_single ( 123456 ) ) { $breadcrumb[] = array( 'url' => site_url( '/blog/' ), 'text' => 'Blog', ); array_splice( $links, 1, -2, $breadcrumb ); } return $links; }