Skip to content
This repository was archived by the owner on Feb 27, 2024. It is now read-only.

Commit 33f349e

Browse files
committed
in case of post type not exist
1 parent a8a037e commit 33f349e

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

command.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,12 @@ function codeat_get_by_url( $args ){
3131
'name' => $last_slug,
3232
'posts_per_page' => 1,
3333
));
34-
$post = $post[ 0 ];
35-
if ( is_object( $post ) ) {
36-
WP_CLI::log( 'post | ' . $post->ID . ' | ' . $post->post_type );
37-
return;
34+
if( isset( $post[ 0 ] ) ) {
35+
$post = $post[ 0 ];
36+
if ( is_object( $post ) ) {
37+
WP_CLI::log( 'post | ' . $post->ID . ' | ' . $post->post_type );
38+
return;
39+
}
3840
}
3941

4042
$taxonomies = get_taxonomies();

0 commit comments

Comments
 (0)