Skip to content

Commit

Permalink
Fix bug when no page was selected for a custom post type archive
Browse files Browse the repository at this point in the history
  • Loading branch information
gchtr committed Oct 17, 2019
1 parent 5a040cb commit c3e8c80
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Types

## 2.4.2 - 2019-10-17

- Fixed bug when no page was selected for a custom post type archive in `Post_Type_Page_Option`.

## 2.4.1 - 2019-08-05

- Added filter to update the title for the post type archive when using `post_type_archive_title()`.
Expand Down
8 changes: 8 additions & 0 deletions lib/Post_Type_Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ public function __construct( $post_type, $post_id, $args = [] ) {
* Inits hooks.
*/
public function init() {
/**
* Bail out if no valid post ID is provided or post ID is 0, which happens when no page is
* selected from dropdown-pages.
*/
if ( ! $this->post_id ) {
return;
}

add_filter( 'register_post_type_args', [ $this, 'update_archive_slug' ], 10, 2 );
add_filter( 'wp_nav_menu_objects', [ $this, 'filter_wp_nav_menu_objects' ], 1 );
add_filter( 'post_type_archive_title', [ $this, 'set_post_type_archive_title' ], 10, 2 );
Expand Down

0 comments on commit c3e8c80

Please sign in to comment.