'; echo ''; ?> name, $filterPostTypes ) ) { continue; } $cats = []; $GLOBALS['blub'] = true; // get posts of current post-type $args = [ 'post_type' => $postType->name, 'posts_per_page' => -1, 'suppress_filters' => false, 'orderby' => $postType->hierarchical ? [ 'parent' => 'ASC', 'menu_order' => 'ASC' ] : 'menu_order', 'order' => 'ASC', ]; if ( $postType->hierarchical ) { $posts = get_pages( $args ); $cats = [ 'none' => $posts, ]; } else { $count = 0; $args = $args + [ 'post_status' => 'any', // workaround for elementor 'meta_key' => 'blub54315321', 'meta_compare' => 'NOT EXISTS', ]; foreach ( $categoryList as $category ) { $args['category'] = $category->term_id; $cats[$category->name] = get_posts( $args ); $count += count( $cats[$category->name] ); } if ( !$count ) { unset( $args['category'] ); $cats[__( 'Uncategorized' )] = get_posts( $args ); } } $GLOBALS['blub'] = false; if ( empty( $cats ) ) { continue; } echo '
'; echo '
' . $postType->label . '' . '
'; echo '
'; $margin = 0; $lastParent = 0; // loop posts of current post-type foreach ( $cats as $catName => $posts ) { if ( empty( $posts ) ) { continue; } if ( !$postType->hierarchical ) { echo '
' . $catName . '
'; } foreach ( $posts as $post ) { $style = ''; if ( empty( $post->post_parent ) ) { $margin = 0; } else if ( $post->post_parent === $lastParent ) { // do nothing } else { // has parent, not same as before $margin += 10; $lastParent = $post->post_parent; } if ( !empty( $margin ) && $postType->hierarchical ) { $style = ' style="margin-left:' . $margin . 'px;" '; } echo '
'; // echo thumb if ( has_post_thumbnail( $post ) ) { // from post-thumbnail $attachmentId = get_post_thumbnail_id( $post->ID ); $path = get_attached_file( $attachmentId ); $url = wp_get_attachment_image_src( $attachmentId, 'thumbnail' ); $url = !empty( $url ) ? $url[0] : ''; } else if ( $post->post_type == 'attachment' ) { // direct from attachment $path = get_attached_file( $post->ID ); $url = wp_get_attachment_image_src( $post->ID, 'thumbnail' ); $url = !empty( $url ) ? $url[0] : ''; } if ( empty( $url ) && class_exists( 'Lib\PostGalleryImageList' ) ) { // from post-gallery $postGalleryImages = Lib\PostGalleryImageList::get( $post->ID ); if ( count( $postGalleryImages ) ) { $firstThumb = array_shift( $postGalleryImages ); $path = $firstThumb['path']; } } if ( !empty( $path ) && class_exists( 'Lib\Thumb' ) ) { $path = explode( '/wp-content/', $path ); $path = '/wp-content/' . array_pop( $path ); $thumbInstance = new Lib\Thumb(); $thumb = $thumbInstance->getThumb( array( 'path' => $path, 'width' => '150', 'height' => '150', 'scale' => '0', ) ); if ( !empty( $thumb['url'] ) ) { echo ''; } } else if ( !empty( $url ) ) { echo ''; } // reset vars $thumb = null; $path = null; $url = null; // echo post-title if ( !empty( $post->post_title ) ) { echo $post->post_title; } else if ( !empty( $post->post_name ) ) { echo $post->post_name; } else { echo $post->ID; } $link = admin_url() . 'post.php?post=' . $post->ID; if ( $postType->name === 'wpcf7' ) { $link = admin_url() . 'admin.php?page=wpcf7&post=' . $post->ID; } echo '
'; echo ''; // add button for elementor-edit if ( defined( 'ELEMENTOR_VERSION' ) ) { echo ''; } echo ''; echo '
'; // .admin-quickbar-post-options echo '
'; // .admin-quickbar-postlist-inner } } echo '
'; echo '
'; } ?>
'; echo ''; if ( defined( 'ELEMENTOR_VERSION' ) ) { echo ''; echo ''; } echo ''; }