Skip to content

Instantly share code, notes, and snippets.

Revisions

  1. thomasfromwood revised this gist May 10, 2022. 1 changed file with 2 additions and 2 deletions.
    Original file line number Diff line number Diff line change
    @@ -17,7 +17,6 @@ function yoast_seo_breadcrumb_add_blog_link( $links ) {
    $blogPage__title = get_the_title($blogPage__id);
    $blogPage__permalink = get_permalink($blogPage__id);


    //add blog link only if post for category archive page
    if ( is_category() && get_post_type() == 'post'):

    @@ -31,5 +30,6 @@ function yoast_seo_breadcrumb_add_blog_link( $links ) {

    endif;

    return $links;
    return $links;

    }
  2. thomasfromwood revised this gist May 10, 2022. 1 changed file with 2 additions and 2 deletions.
    Original file line number Diff line number Diff line change
    @@ -5,9 +5,9 @@
    * Last Tested: May 10 2022 using Yoast SEO 18.8 on WordPress 5.9.3
    */

    add_filter( 'wpseo_breadcrumb_links', 'yoast_seo_breadcrumb_append_link' );
    add_filter( 'wpseo_breadcrumb_links', 'yoast_seo_breadcrumb_add_blog_link' );

    function yoast_seo_breadcrumb_append_link( $links ) {
    function yoast_seo_breadcrumb_add_blog_link( $links ) {

    //get global post informations
    global $post;
  3. thomasfromwood revised this gist May 10, 2022. No changes.
  4. thomasfromwood revised this gist May 10, 2022. 4 changed files with 35 additions and 91 deletions.
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    <?php
    /*
    * Add blog link on category archive page to the Yoast SEO breadcrumbs
    * Credit: https://gist.github.com/amboutwe/ea0791e184668a5c7bd7bbe357c598e9#file-yoast_seo_breadcrumb_append_link-php
    * Last Tested: May 10 2022 using Yoast SEO 18.8 on WordPress 5.9.3
    */

    add_filter( 'wpseo_breadcrumb_links', 'yoast_seo_breadcrumb_append_link' );

    function yoast_seo_breadcrumb_append_link( $links ) {

    //get global post informations
    global $post;

    //get the blog page informations
    $blogPage__id = get_option( 'page_for_posts' );
    $blogPage__title = get_the_title($blogPage__id);
    $blogPage__permalink = get_permalink($blogPage__id);


    //add blog link only if post for category archive page
    if ( is_category() && get_post_type() == 'post'):

    //customize breakcrumb
    $breadcrumb[] = array(
    'url' => $blogPage__permalink,
    'text' => $blogPage__title,
    );

    array_splice( $links, 1, -2, $breadcrumb );

    endif;

    return $links;
    }
    25 changes: 0 additions & 25 deletions yoast_seo_breadcrumb_add_woo_shop.php
    Original file line number Diff line number Diff line change
    @@ -1,25 +0,0 @@
    <?php
    /********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/

    /*
    * Add shop link to the Yoast SEO breadcrumbs for a WooCommerce shop page.
    * Credit: https://wordpress.stackexchange.com/users/8495/rjb
    * Last Tested: Apr 20 2017 using Yoast SEO 4.6 on WordPress 4.7.3
    */

    add_filter( 'wpseo_breadcrumb_links', 'wpseo_breadcrumb_add_woo_shop_link' );

    function wpseo_breadcrumb_add_woo_shop_link( $links ) {
    global $post;

    if ( is_woocommerce() ) {
    $breadcrumb[] = array(
    'url' => get_permalink( woocommerce_get_page_id( 'shop' ) ),
    'text' => 'Shop',
    );

    array_splice( $links, 1, -2, $breadcrumb );
    }

    return $links;
    }
    36 changes: 0 additions & 36 deletions yoast_seo_breadcrumb_append_link.php
    Original file line number Diff line number Diff line change
    @@ -1,36 +0,0 @@
    <?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;
    }
    30 changes: 0 additions & 30 deletions yoast_seo_breadcrumb_remove_limited.php
    Original file line number Diff line number Diff line change
    @@ -1,30 +0,0 @@
    <?php
    /********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/

    /*
    * Add a link to the Yoast SEO breadcrumbs
    * Credit: Yoast team
    * Last Tested: Feb 25 2019 using Yoast SEO 9.6 on WordPress 5.1
    *********
    * 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', 'wpseo_breadcrumb_remove_limited' );

    function wpseo_breadcrumb_remove_limited( $breadcrumbs ) {
    if ( is_single ( 123456 ) ) {
    return false;
    }
    else {
    return $breadcrumbs;
    }
    }
  5. @amboutwe amboutwe revised this gist Feb 25, 2019. No changes.
  6. @amboutwe amboutwe revised this gist Feb 25, 2019. 1 changed file with 30 additions and 0 deletions.
    30 changes: 30 additions & 0 deletions yoast_seo_breadcrumb_remove_limited.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    <?php
    /********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/

    /*
    * Add a link to the Yoast SEO breadcrumbs
    * Credit: Yoast team
    * Last Tested: Feb 25 2019 using Yoast SEO 9.6 on WordPress 5.1
    *********
    * 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', 'wpseo_breadcrumb_remove_limited' );

    function wpseo_breadcrumb_remove_limited( $breadcrumbs ) {
    if ( is_single ( 123456 ) ) {
    return false;
    }
    else {
    return $breadcrumbs;
    }
    }
  7. @amboutwe amboutwe revised this gist Nov 30, 2018. 1 changed file with 36 additions and 0 deletions.
    36 changes: 36 additions & 0 deletions yoast_seo_breadcrumb_append_link.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,36 @@
    <?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;
    }
  8. @amboutwe amboutwe renamed this gist Jun 17, 2017. 1 changed file with 0 additions and 0 deletions.
  9. @amboutwe amboutwe renamed this gist Jun 17, 2017. 1 changed file with 0 additions and 0 deletions.
  10. @amboutwe amboutwe renamed this gist Jun 17, 2017. 1 changed file with 0 additions and 0 deletions.
  11. @amboutwe amboutwe renamed this gist Jun 17, 2017. 1 changed file with 0 additions and 0 deletions.
  12. @amboutwe amboutwe revised this gist Jun 8, 2017. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions yoast-seo-breadcrumb-add-shop-link-woo.php
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,5 @@
    <?php
    /********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/

    /*
    * Add shop link to the Yoast SEO breadcrumbs for a WooCommerce shop page.
  13. @amboutwe amboutwe revised this gist Apr 20, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion yoast-seo-breadcrumb-add-shop-link-woo.php
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    <?php

    /*
    * Remove a link from the Yoast SEO breadcrumbs
    * Add shop link to the Yoast SEO breadcrumbs for a WooCommerce shop page.
    * Credit: https://wordpress.stackexchange.com/users/8495/rjb
    * Last Tested: Apr 20 2017 using Yoast SEO 4.6 on WordPress 4.7.3
    */
  14. @amboutwe amboutwe created this gist Apr 20, 2017.
    24 changes: 24 additions & 0 deletions yoast-seo-breadcrumb-add-shop-link-woo.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    <?php

    /*
    * Remove a link from the Yoast SEO breadcrumbs
    * Credit: https://wordpress.stackexchange.com/users/8495/rjb
    * Last Tested: Apr 20 2017 using Yoast SEO 4.6 on WordPress 4.7.3
    */

    add_filter( 'wpseo_breadcrumb_links', 'wpseo_breadcrumb_add_woo_shop_link' );

    function wpseo_breadcrumb_add_woo_shop_link( $links ) {
    global $post;

    if ( is_woocommerce() ) {
    $breadcrumb[] = array(
    'url' => get_permalink( woocommerce_get_page_id( 'shop' ) ),
    'text' => 'Shop',
    );

    array_splice( $links, 1, -2, $breadcrumb );
    }

    return $links;
    }