Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sitemap: post__not_in requires a value to be an array #62

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

- fix: Correctly parse excluded Post/Term IDs when returning nodes for Sitemap. Props @marcinkrzeminski

## v0.0.15

- chore: Update Composer dev-dependencies.
Expand Down
3 changes: 2 additions & 1 deletion src/Type/WPObject/Settings/Sitemap/ContentType.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public static function get_connections(): array {
return [
'connectedContentNodes' => [
'toType' => 'ContentNode',
'description' => __( 'The connected authors whose URLs are included in the sitemap', 'wp-graphql-rank-math' ),
'description' => __( 'The connected content nodes whose URLs are included in the sitemap', 'wp-graphql-rank-math' ),
'resolve' => static function ( $source, $args, $context, $info ) {
if ( empty( $source['isInSitemap'] ) ) {
return null;
Expand All @@ -39,6 +39,7 @@ public static function get_connections(): array {
$resolver = new PostObjectConnectionResolver( $source, $args, $context, $info, $source['type'] );

$excluded_post_ids = Helper::get_settings( 'sitemap.exclude_posts' );
$excluded_post_ids = ! empty( $excluded_post_ids ) ? array_map( 'absint', explode( ',', $excluded_post_ids ) ) : null;

if ( ! empty( $excluded_post_ids ) ) {
$resolver->set_query_arg( 'post__not_in', $excluded_post_ids );
Expand Down
3 changes: 2 additions & 1 deletion src/Type/WPObject/Settings/Sitemap/Taxonomy.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public static function get_connections(): array {
return [
'connectedTerms' => [
'toType' => 'TermNode',
'description' => __( 'The connected authors whose URLs are included in the sitemap', 'wp-graphql-rank-math' ),
'description' => __( 'The connected terms whose URLs are included in the sitemap', 'wp-graphql-rank-math' ),
'resolve' => static function ( $source, $args, $context, $info ) {
if ( empty( $source['isInSitemap'] ) ) {
return null;
Expand All @@ -39,6 +39,7 @@ public static function get_connections(): array {
$resolver = new TermObjectConnectionResolver( $source, $args, $context, $info, $source['type'] );

$excluded_term_ids = Helper::get_settings( 'sitemap.exclude_terms' );
$excluded_term_ids = ! empty( $excluded_term_ids ) ? array_map( 'absint', explode( ',', $excluded_term_ids ) ) : null;

if ( ! empty( $excluded_term_ids ) ) {
$resolver->set_query_arg( 'exclude', $excluded_term_ids );
Expand Down
Loading