Unlink parent page

#393463
  • Resolved Azzurra Maggia
    Rank Math business

    Hi there!

    I have some pages which are child pages to a page that has no content, basically I just needed the URL to have a certain structure:

    mydomain.com/parent-name/child-name

    The parent page is no index and not reachable from anywhere except that Breadcrumbs do carry a link to the page. Is it possible to keep the Breadcrumbs structure as it is but unlink the parent page?
    e.g.
    Home > Parent name (no link) > Child name (Link)

    Thank you for your help!

Viewing 7 replies - 1 through 7 (of 7 total)
  • Hello,

    Thank you for contacting Rank Math support, and sorry for any inconvenience that might have been caused due to that.

    Please note that adding a non-existing parent page may confuse the search engine. However, if you do wish to remove the breadcrumbs link, kindly refer to this filter code here and insert it in your theme’s functions.php file:

    /**
     * Allow changing or removing the Breadcrumb items
     *
     * @param array       $crumbs The crumbs array.
     * @param Breadcrumbs $this   Current breadcrumb object.
     */
    add_filter( 'rank_math/frontend/breadcrumb/items', function( $crumbs, $class ) {
        $crumbs[1][1] = null;
        return $crumbs;
    }, 10, 2);

    Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.

    Hi Jeremy!
    Thank you for your reply. I copied the code, it did deactivate the link but only in the blog section (so now Blog is not active). Is there a way to target only a specific ID with the function? I don’t want to unlink the Blog page.

    Thanks!

    Hello,

    Please use the following filter:

    add_filter( 'rank_math/frontend/breadcrumb/items', function( $crumbs, $class ) {
        global $post;
        if($post->ID == '') { //ID OF THE POST
            $crumbs[1][1] = null;
            return $crumbs;
        }
        return $crumbs;
    }, 10, 2);

    Hope this helps. Let us know if you need any other assistance.

    Hi Jaideep,
    thank you for your reply. I’ve added this code then:

    add_filter( ‘rank_math/frontend/breadcrumb/items’, function( $crumbs, $class ) {
    global $post;
    if($post->ID == ‘7180’) { //ID OF THE POST
    $crumbs[1][1] = null;
    return $crumbs;
    }
    return $crumbs;
    }, 10, 2);

    But it seems it’s not working as nothing happens

    Hello,

    Please share the URL of the post for which you have applied the code so we can check and assist you further.

    Looking forward to helping you.

    Thanks.

    Thank you Jaideep,
    in the end the SEO specialist decided for a redirect. So we sorted it out like that.
    But I will definitely use your code on another website and let you guys know if I have any problems.
    Thank you for your time!
    Have a good day

    Hello,

    We are super happy that you have sorted it out.

    If you have another question in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.

    Thank you.

Viewing 7 replies - 1 through 7 (of 7 total)

You must be logged in to reply to this ticket.