get_posts example

?> </ul> </div><!-- /.tabs-panel --> <div id="<?php echo esc_attr( "tabs-panel-posttype-{$post_type_name}-search" ); ?>" class="tabs-panel <?php echo ( 'search' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>" role="region" aria-label="<?php echo esc_attr( $post_type->labels->search_items ); ?>" tabindex="0" > <?php             if ( isset( $_REQUEST[ "quick-search-posttype-{$post_type_name}] ) ) {
                $searched       = esc_attr( $_REQUEST[ "quick-search-posttype-{$post_type_name}] );
                $search_results = get_posts(
                    array(
                        's'         => $searched,
                        'post_type' => $post_type_name,
                        'fields'    => 'all',
                        'order'     => 'DESC',
                    )
                );
            } else {
                $searched       = '';
                $search_results = array();
            }
            
'post_type'      => array_keys( $post_types ),
        'post_status'    => 'any',
        'posts_per_page' => 50,
    );

    $search = wp_unslash( $_POST['ps'] );

    if ( '' !== $search ) {
        $args['s'] = $search;
    }

    $posts = get_posts( $args );

    if ( ! $posts ) {
        wp_send_json_error( __( 'No items found.' ) );
    }

    $html = '<table class="widefat"><thead><tr><th class="found-radio"><br /></th><th>' . __( 'Title' ) . '</th><th class="no-break">' . __( 'Type' ) . '</th><th class="no-break">' . __( 'Date' ) . '</th><th class="no-break">' . __( 'Status' ) . '</th></tr></thead><tbody>';
    $alt  = '';
    foreach ( $posts as $post ) {
        $title = trim( $post->post_title ) ? $post->post_title : __( '(no title)' );
        $alt   = ( 'alternate' === $alt ) ? '' : 'alternate';

        
if ( ! $user ) {
            return $this->error;
        }

        if ( ! current_user_can( 'edit_pages' ) ) {
            return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit pages.' ) );
        }

        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
        do_action( 'xmlrpc_call', 'wp.getPages', $args$this );

        $pages     = get_posts(
            array(
                'post_type'   => 'page',
                'post_status' => 'any',
                'numberposts' => $num_pages,
            )
        );
        $num_pages = count( $pages );

        // If we have pages, put together their info.         if ( $num_pages >= 1 ) {
            $pages_struct = array();

            
'include'    => '',
            'exclude'    => '',
            'link'       => '',
        ),
        $attr,
        'gallery'
    );

    $id = (int) $atts['id'];

    if ( ! empty( $atts['include'] ) ) {
        $_attachments = get_posts(
            array(
                'include'        => $atts['include'],
                'post_status'    => 'inherit',
                'post_type'      => 'attachment',
                'post_mime_type' => 'image',
                'order'          => $atts['order'],
                'orderby'        => $atts['orderby'],
            )
        );

        $attachments = array();
        
unset( $sticky_posts[ $offset ] );
                }
            }

            // If any posts have been excluded specifically, Ignore those that are sticky.             if ( ! empty( $sticky_posts ) && ! empty( $q['post__not_in'] ) ) {
                $sticky_posts = array_diff( $sticky_posts$q['post__not_in'] );
            }

            // Fetch sticky posts that weren't in the query results.             if ( ! empty( $sticky_posts ) ) {
                $stickies = get_posts(
                    array(
                        'post__in'               => $sticky_posts,
                        'post_type'              => $post_type,
                        'post_status'            => 'publish',
                        'posts_per_page'         => count( $sticky_posts ),
                        'suppress_filters'       => $q['suppress_filters'],
                        'cache_results'          => $q['cache_results'],
                        'update_post_meta_cache' => $q['update_post_meta_cache'],
                        'update_post_term_cache' => $q['update_post_term_cache'],
                        'lazy_load_term_meta'    => $q['lazy_load_term_meta'],
                    )
                );
if ( ! empty( $args['exclude_restore_dismissed'] ) ) {
            unset( $args['exclude_restore_dismissed'] );
            $args['meta_query'] = array(
                array(
                    'key'     => '_customize_restore_dismissed',
                    'compare' => 'NOT EXISTS',
                ),
            );
        }

        return get_posts( $args );
    }

    /** * Dismisses all of the current user's auto-drafts (other than the present one). * * @since 4.9.0 * @return int The number of auto-drafts that were dismissed. */
    protected function dismiss_user_auto_draft_changesets() {
        $changeset_autodraft_posts = $this->get_changeset_posts(
            array(
                


        /** * Filters the post query arguments for the 'Recent Drafts' dashboard widget. * * @since 4.4.0 * * @param array $query_args The query arguments for the 'Recent Drafts' dashboard widget. */
        $query_args = apply_filters( 'dashboard_recent_drafts_query_args', $query_args );

        $drafts = get_posts( $query_args );
        if ( ! $drafts ) {
            return;
        }
    }

    echo '<div class="drafts">';

    if ( count( $drafts ) > 3 ) {
        printf(
            '<p class="view-all"><a href="%s">%s</a></p>' . "\n",
            esc_url( admin_url( 'edit.php?post_status=draft' ) ),
            

    if ( ! is_array( $metadata ) ) {
        $metadata = array();
    }

    if ( $support && ! empty( $metadata['image']['data'] ) ) {
        // Check for existing cover.         $hash   = md5( $metadata['image']['data'] );
        $posts  = get_posts(
            array(
                'fields'         => 'ids',
                'post_type'      => 'attachment',
                'post_mime_type' => $metadata['image']['mime'],
                'post_status'    => 'inherit',
                'posts_per_page' => 1,
                'meta_key'       => '_cover_hash',
                'meta_value'     => $hash,
            )
        );
        $exists = reset( $posts );

        
$excluded_terms = $inverse_terms;
        }

        $query_args['tax_query'] = array(
            array(
                'taxonomy' => $taxonomy,
                'terms'    => array_merge( $term_array$excluded_terms ),
            ),
        );
    }

    return get_posts( $query_args );
}

/** * Retrieves the previous post link that is adjacent to the current post. * * @since 3.7.0 * * @param string $format Optional. Link anchor format. Default '&laquo; %link'. * @param string $link Optional. Link permalink format. Default '%title'. * @param bool $in_same_term Optional. Whether link should be in the same taxonomy term. * Default false. * @param int[]|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs. * Default empty. * @param string $taxonomy Optional. Taxonomy, if `$in_same_term` is true. Default 'category'. * @return string The link URL of the previous post in relation to the current post. */

    do_action( 'do_all_pings' );
}

/** * Performs all pingbacks. * * @since 5.6.0 */
function do_all_pingbacks() {
    $pings = get_posts(
        array(
            'post_type'        => get_post_types(),
            'suppress_filters' => false,
            'nopaging'         => true,
            'meta_key'         => '_pingme',
            'fields'           => 'ids',
        )
    );

    foreach ( $pings as $ping ) {
        delete_post_meta( $ping, '_pingme' );
        
'update_menu_item_cache' => true,
        'tax_query'              => array(
            array(
                'taxonomy' => 'nav_menu',
                'field'    => 'term_taxonomy_id',
                'terms'    => $menu->term_taxonomy_id,
            ),
        ),
    );
    $args     = wp_parse_args( $args$defaults );
    if ( $menu->count > 0 ) {
        $items = get_posts( $args );
    } else {
        $items = array();
    }

    $items = array_map( 'wp_setup_nav_menu_item', $items );

    if ( ! is_admin() ) { // Remove invalid items only on front end.         $items = array_filter( $items, '_is_valid_nav_menu_item' );
    }

    if ( ARRAY_A === $args['output'] ) {
        


    $defaults = array(
        'numberposts' => -1,
        'post_type'   => 'any',
        'post_status' => 'any',
        'post_parent' => 0,
    );

    $parsed_args = wp_parse_args( $args$defaults );

    $children = get_posts( $parsed_args );

    if ( ! $children ) {
        return $kids;
    }

    if ( ! empty( $parsed_args['fields'] ) ) {
        return $children;
    }

    update_post_cache( $children );

    
/** * Gets the header images uploaded for the active theme. * * @since 3.2.0 * * @return array */
function get_uploaded_header_images() {
    $header_images = array();

    // @todo Caching.     $headers = get_posts(
        array(
            'post_type'  => 'attachment',
            'meta_key'   => '_wp_attachment_is_custom_header',
            'meta_value' => get_option( 'stylesheet' ),
            'orderby'    => 'none',
            'nopaging'   => true,
        )
    );

    if ( empty( $headers ) ) {
        return array();
    }
'post_type'   => $object_name,
            );

            // Add suppression array to arguments for get_posts.             if ( ! empty( $suppress_page_ids ) ) {
                $args['post__not_in'] = $suppress_page_ids;
            }

            $posts = array_merge(
                $posts,
                $important_pages,
                get_posts( $args )
            );

            foreach ( $posts as $post ) {
                $post_title = $post->post_title;
                if ( '' === $post_title ) {
                    /* translators: %d: ID of a post. */
                    $post_title = sprintf( __( '#%d (no title)' )$post->ID );
                }

                $post_type_label = get_post_type_object( $post->post_type )->labels->singular_name;
                $post_states     = get_post_states( $post );
                
printf(
            /* translators: 1: Privacy Policy guide URL, 2: Additional link attributes, 3: Accessibility text. */
            __( 'Need help putting together your new Privacy Policy page? <a href="%1$s" %2$s>Check out our privacy policy guide%3$s</a> for recommendations on what content to include, along with policies suggested by your plugins and theme.' ),
            esc_url( admin_url( 'options-privacy.php?tab=policyguide' ) ),
            '',
            ''
        );
        ?> </p> <hr> <?php     $has_pages = (bool) get_posts(
        array(
            'post_type'      => 'page',
            'posts_per_page' => 1,
            'post_status'    => array(
                'publish',
                'draft',
            ),
        )
    );
    ?> <table class="form-table tools-privacy-policy-page" role="presentation"> <tr> <th scope="row"> <label for="create-page">
Home | Imprint | This part of the site doesn't use cookies.