next_post example

if ( isset( $post_type_obj->_default_query ) ) {
                $args = array_merge( $args(array) $post_type_obj->_default_query );
            }

            $search_results_query = new WP_Query( $args );
            if ( ! $search_results_query->have_posts() ) {
                return;
            }

            while ( $search_results_query->have_posts() ) {
                $post = $search_results_query->next_post();

                if ( 'markup' === $response_format ) {
                    $var_by_ref = $post->ID;
                    echo walk_nav_menu_tree(
                        array_map( 'wp_setup_nav_menu_item', array( get_post( $var_by_ref ) ) ),
                        0,
                        (object) $args
                    );
                } elseif ( 'json' === $response_format ) {
                    echo wp_json_encode(
                        array(
                            
array(
                        'taxonomy' => 'wp_theme',
                        'field'    => 'name',
                        'terms'    => $attributes['theme'],
                    ),
                ),
                'posts_per_page'      => 1,
                'no_found_rows'       => true,
                'lazy_load_term_meta' => false, // Do not lazy load term meta, as template parts only have one term.             )
        );
        $template_part_post  = $template_part_query->have_posts() ? $template_part_query->next_post() : null;
        if ( $template_part_post ) {
            // A published post might already exist if this template part was customized elsewhere             // or if it's part of a customized template.             $content    = $template_part_post->post_content;
            $area_terms = get_the_terms( $template_part_post, 'wp_template_part_area' );
            if ( ! is_wp_error( $area_terms ) && false !== $area_terms ) {
                $area = $area_terms[0]->name;
            }
            /** * Fires when a block template part is loaded from a template post stored in the database. * * @since 5.9.0 * * @param string $template_part_id The requested template part namespaced to the theme. * @param array $attributes The block attributes. * @param WP_Post $template_part_post The template part post object. * @param string $content The template part content. */

function start_wp() {
    global $wp_query;

    _deprecated_function( __FUNCTION__, '1.5.0', __('new WordPress Loop') );

    // Since the old style loop is being used, advance the query iterator here.     $wp_query->next_post();

    setup_postdata( get_post() );
}

/** * Returns or prints a category ID. * * @since 0.71 * @deprecated 0.71 Use get_the_category() * @see get_the_category() * * @param bool $display Optional. Whether to display the output. Default true. * @return int Category ID. */
if ( -1 == $this->current_post ) { // Loop has just started.             /** * Fires once the loop is started. * * @since 2.0.0 * * @param WP_Query $query The WP_Query instance (passed by reference). */
            do_action_ref_array( 'loop_start', array( &$this ) );
        }

        $post = $this->next_post();
        $this->setup_postdata( $post );
    }

    /** * Determines whether there are more posts available in the loop. * * Calls the {@see 'loop_end'} action when the loop is complete. * * @since 1.5.0 * * @return bool True if posts are available, false if end of the loop. */
Home | Imprint | This part of the site doesn't use cookies.