How to check if page exists in Multisite?
Question
I have the following function to check if the page exists in WordPress by using the path:
private function page_exists( $path ) {
$post_types = apply_filters( 'get_page_by_path_post_types', [ 'page', 'post' ] );
foreach ( $post_types as $pt ) {
if( get_page_by_path( $path, OBJECT, $pt ) !== null ) {
return true;
}
}
return false;
}
The problem is that in multisite the function fails. I searched around but I couldn’t find a Multisite function similar to get_page_by_path
0
3 months
0 Answers
16 views
0
Leave an answer
You must login or register to add a new answer .