Skip to content

Commit

Permalink
Merge pull request #304 from Yoast/revert-249-ignore-hierarchy-check-…
Browse files Browse the repository at this point in the history
…filter

Revert "ignore hierarchy check filter doc"
  • Loading branch information
igorschoester committed May 23, 2024
2 parents 875a4c3 + f567030 commit 7d3818b
Showing 1 changed file with 0 additions and 28 deletions.
28 changes: 0 additions & 28 deletions docs/features/indexables/filters.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,31 +131,3 @@ To use indexables instead of content scanning to find all content images. Enable
```php
add_filter( 'wpseo_force_creating_and_using_attachment_indexables', '__return_true' );
```

## Ignore hierarchy check

When adding a term with `wp_set_object_terms` right after `wp_insert_post`, the hierarchy check is preventing the indexation of the term hierarcy.
That in turn will result in worng term (default term) in Yoast breadcrumbs. Use this filter to fix it.

### Usage

Before using `wp_set_object_terms` together with `wp_insert_post`.


The example below shows how you can use this filter to ignore hierarcy check when using `wp_set_object_terms` together with `wp_insert_post`.
```php
<?php
add_filter( 'wpseo_hierarchy_ignore_already_saved', '__return_true');

$post_id = wp_insert_post([
'post_type' => 'post',
'post_title' => 'Test post',
'post_content' => '',
'post_status' => 'publish'
]);

if ($post_id != 0) {
wp_set_object_terms( $post_id, 'test_term', 'category');
}
```

0 comments on commit 7d3818b

Please sign in to comment.