Title: Schema filter
Last modified: November 27, 2023

---

# Schema filter

 *  Resolved [berkmh](https://wordpress.org/support/users/berkmh/)
 * (@berkmh)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/schema-filter-2/)
 * do you guys have a filter to control the schema output of 5.0? I only want the
   breadcrumbs schema running since I have hardcoded all other schema…

Viewing 1 replies (of 1 total)

 *  Plugin Author [Sybre Waaijer](https://wordpress.org/support/users/cybr/)
 * (@cybr)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/schema-filter-2/#post-17237463)
 * Hello!
 * If you just want the breadcrumbs, you can use this:
    `tsf()->breadcrumbs()->get_breadcrumb_list()`;
   you’ll have to transform that list into a Schema, where `url` is the ListItem’s`
   item`, and `name` is `name`.
 * e.g.:
 *     ```
       $list = tsf()->breadcrumbs()->get_breadcrumb_list();
   
       $list_items = [];
   
       foreach ( $list as $i => $item ) {
       	$list_items[] = [
       		'@type'    => 'ListItem',
       		'position' => $i + 1, // Let's not create 0
       		'item'     => sanitize_url( $item['url'] ),
       		'name'     => tsf()->filter()->sanitize()->metadata_content( $item['name'] ),
       	];
       }
   
       if ( $list_items ) 
       	// Pop off the last URL, so search engines will use the page URL instead.
       	unset( $list_items[ array_key_last( $list_items ) ]['item'] );
   
       	$schema = [
       		'@type'           => 'BreadcrumbList',
       		'itemListElement' => $list_items,
       	];
       }
       ```
   
 * Note that you must wrap this in `if ( function_exists( 'tsf' ) ) {}` to prevent
   crashing when TSF is disabled.
 * Alternatively, you can use the filter below to augment TSF’s Schema.org output
   to only provide breadcrumbs — however, I cannot promise it’ll work forever since
   I never considered your type of request. Still, you’re free to reach out for 
   an updated version if necessary.
 *     ```
       add_filter(
       	'the_seo_framework_schema_graph_data',
       	function( $graph ) {
   
       		foreach ( $graph as $entity ) {
       			if ( isset( $entity['breadcrumb'] ) ) {
       				return $entity['breadcrumb'];
       			}
       		}
   
       		// Empty graph if there's no breadcrumb.
       		return [];
       	},
       );
       ```
   
 * I hope this helps. Cheers!

Viewing 1 replies (of 1 total)

The topic ‘Schema filter’ is closed to new replies.

 * ![](https://ps.w.org/autodescription/assets/icon.svg?rev=3000376)
 * [The SEO Framework – Fast, Automated, Effortless.](https://wordpress.org/plugins/autodescription/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/autodescription/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/autodescription/)
 * [Active Topics](https://wordpress.org/support/plugin/autodescription/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/autodescription/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/autodescription/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Sybre Waaijer](https://wordpress.org/support/users/cybr/)
 * Last activity: [2 years, 6 months ago](https://wordpress.org/support/topic/schema-filter-2/#post-17237463)
 * Status: resolved