Skip to content

Commit f1b3147

Browse files
committed
Helper for AIOSEO to determine noindex status.
1 parent e33efd5 commit f1b3147

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

inc/seo-compat.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ function is_noindex( $post ) {
2424
return true;
2525
}
2626

27+
// Check All in One SEO noindex.
28+
if ( is_aioseo_noindex( $post ) ) {
29+
return true;
30+
}
31+
2732
return false; // Default to not noindex.
2833
}
2934

@@ -49,3 +54,26 @@ function is_yoast_noindex( $post ) {
4954

5055
return 'noindex' === $robots['index'];
5156
}
57+
58+
/**
59+
* Check All in One SEO noindex status.
60+
*
61+
* @param \WP_Post|int $post The post object or ID.
62+
* @return bool True if AIOSEO sets the post to noindex, false otherwise.
63+
*/
64+
function is_aioseo_noindex( $post ) {
65+
if ( ! function_exists( 'aioseo' ) ) {
66+
return false; // AIOSEO is not active.
67+
}
68+
69+
$post = get_post( $post );
70+
$post_id = $post->ID;
71+
72+
$post_meta = aioseo()->meta->metaData->getMetaData( $post_id );
73+
74+
if ( ! $post_meta->robots_default && isset( $post_meta->robots_noindex ) ) {
75+
return $post_meta->robots_noindex;
76+
}
77+
78+
return aioseo()->helpers->isPostTypeNoindexed( get_post_type( $post ) );
79+
}

0 commit comments

Comments
 (0)