Skip to content

Commit

Permalink
added function to get already exist portfolio page
Browse files Browse the repository at this point in the history
  • Loading branch information
Fellan-91 committed Dec 21, 2023
1 parent 25e1779 commit 287abe7
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions classes/class-archive-mapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -1094,6 +1094,35 @@ public static function create_archive_page( $custom_slug = 'portfolio' ) {
}
}

/**
* Get Unset Portfolio Page.
*
* @return int|bool
*/
public static function get_unset_archive_page() {
$query_opts = array(
'post_status' => 'publish',
'ignore_sticky_posts' => 1,
'posts_per_page' => 50,
'post_type' => 'page',
'update_post_meta_cache' => false,
'update_post_term_cache' => false,
'meta_key' => '_vp_post_type_mapped',
);

$search_results = new WP_Query( $query_opts );

if ( $search_results->have_posts() ) {
while ( $search_results->have_posts() ) {
$search_results->the_post();
$post_id = $search_results->post->ID;
break;
}
}

return $post_id ?? false;
}

/**
* Add a post display state for special Portfolio Archive page in the pages list table.
*
Expand Down

0 comments on commit 287abe7

Please sign in to comment.