File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff 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+ }
You can’t perform that action at this time.
0 commit comments