★ How to assign a Custom Field to Breadcrumb Title ?

#66178
  • Resolved Surendra.S
    Rank Math free

    Is is possible to assign a Custom Field to ‘Breadcrumb Title’ instead of manually filling it for every custom post ?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Anonymous
    Rank Math free

    Thank you for contacting Rank Math today.

    Sorry to disappoint but that feature is unfortunately not available at this time.

    With that being said, there are existing feature requests, so I’ve added your vote to our internal suggestions lists. If your suggestions are something that we’re able to introduce, I’ll be sure to let you know.

    Hello,

    Thank you for contacting Rank Math today.

    Here is a filter you can customize.

    /**
     * this is an example to remove the second item in your post breadcrumbs
     * 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 ) {
            // Check if we are viewing single posts
    	if(is_singular('post')){	
                    // Apply here your custom login to generate the final
                    // element of the breadcrumb (the breadcrumb title)
                    $newBreadcrumbTitle = "example";
                    // The last element in the $crumbs array is the post's
                    // breadcrumb title, so we have to update it:
                    $crumbs[count($crumbs)-1] = $newBreadcrumbTitle;
    	}
            // And return the breadcrumbs
    	return $crumbs;
    }, 10, 2);

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

    Thank You ! Can you pls assist a bit how to do it ?

    I mean, I have a Custom Post Type called ‘Jobs’.

    For each Single Job Post, I want to show the BreadCrumb Title from a Custom Field called ‘cf_job_short_title’

    So, if any data available in this Custom Field ‘cf_job_short_title’, then that will be shown as BreadCrumb Title. If this Custom Field was not set for any JOB, then the default Page (JOB) Title will be shown as usual.

    How should I modify above filter for this ?

    Hello,

    You can modify the breadcrumb value to get the value of the custom field.

    
    //get value
    $custom_field_value = get_custom_field_value();
    //then assign the value to breadcrumb
     $crumbs[count($crumbs)-1] = $custom_field_value;
    

    This is just a format of how to, for further customization please seek the help of a developer

    Hope that helps. If you have any further question(s), please let us know. Thank you.

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

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

The ticket ‘★ How to assign a Custom Field to Breadcrumb Title ?’ is closed to new replies.