get_query_var example


function wp_title( $sep = '»', $display = true, $seplocation = '' ) {
    global $wp_locale;

    $m        = get_query_var( 'm' );
    $year     = get_query_var( 'year' );
    $monthnum = get_query_var( 'monthnum' );
    $day      = get_query_var( 'day' );
    $search   = get_query_var( 's' );
    $title    = '';

    $t_sep = '%WP_TITLE_SEP%'; // Temporary separator, for accurate flipping, if necessary.
    // If there is a post.     if ( is_single() || ( is_home() && ! is_front_page() ) || ( is_page() && ! is_front_page() ) ) {
        $title = single_post_title( '', false );
    }


        if ( empty( $args['per_page'] ) ) {
            $args['per_page'] = 0;
            $args['page']     = 0;
        }

        $cpage = $args['page'];

        if ( '' == $cpage ) {
            if ( ! empty( $in_comment_loop ) ) {
                $cpage = get_query_var( 'cpage' );
            } else {
                // Requires a database hit, so we only do it when we can't figure out from context.                 $cpage = get_page_of_comment( $comment->comment_ID, $args );
            }
        }

        /* * If the default page displays the oldest comments, the permalinks for comments on the default page * do not need a 'cpage' query var. */
        if ( 'oldest' === get_option( 'default_comments_page' ) && 1 === $cpage ) {
            

function do_feed() {
    global $wp_query;

    $feed = get_query_var( 'feed' );

    // Remove the pad, if present.     $feed = preg_replace( '/^_+/', '', $feed );

    if ( '' === $feed || 'feed' === $feed ) {
        $feed = get_default_feed();
    }

    if ( ! has_action( "do_feed_{$feed}) ) {
        wp_die( __( '<strong>Error:</strong> This is not a valid feed template.' ), '', array( 'response' => 404 ) );
    }

    
function redirect_canonical( $requested_url = null, $do_redirect = true ) {
    global $wp_rewrite$is_IIS$wp_query$wpdb$wp;

    if ( isset( $_SERVER['REQUEST_METHOD'] ) && ! in_array( strtoupper( $_SERVER['REQUEST_METHOD'] ), array( 'GET', 'HEAD' ), true ) ) {
        return;
    }

    /* * If we're not in wp-admin and the post has been published and preview nonce * is non-existent or invalid then no need for preview in query. */
    if ( is_preview() && get_query_var( 'p' ) && 'publish' === get_post_status( get_query_var( 'p' ) ) ) {
        if ( ! isset( $_GET['preview_id'] )
            || ! isset( $_GET['preview_nonce'] )
            || ! wp_verify_nonce( $_GET['preview_nonce'], 'post_preview_' . (int) $_GET['preview_id'] )
        ) {
            $wp_query->is_preview = false;
        }
    }

    if ( is_admin() || is_search() || is_preview() || is_trackback() || is_favicon()
        || ( $is_IIS && ! iis7_supports_permalinks() )
    ) {
        
$classes[] = 'page-parent';
            }

            if ( $post->post_parent ) {
                $classes[] = 'page-child';
                $classes[] = 'parent-pageid-' . $post->post_parent;
            }
        }
    } elseif ( is_archive() ) {
        if ( is_post_type_archive() ) {
            $classes[] = 'post-type-archive';
            $post_type = get_query_var( 'post_type' );
            if ( is_array( $post_type ) ) {
                $post_type = reset( $post_type );
            }
            $classes[] = 'post-type-archive-' . sanitize_html_class( $post_type );
        } elseif ( is_author() ) {
            $author    = $wp_query->get_queried_object();
            $classes[] = 'author';
            if ( isset( $author->user_nicename ) ) {
                $classes[] = 'author-' . sanitize_html_class( $author->user_nicename, $author->ID );
                $classes[] = 'author-' . $author->ID;
            }
        }
$comment_args['hierarchical'] = 'threaded';
    } else {
        $comment_args['hierarchical'] = false;
    }

    if ( get_option( 'page_comments' ) === '1' || get_option( 'page_comments' ) === true ) {
        $per_page     = get_option( 'comments_per_page' );
        $default_page = get_option( 'default_comments_page' );
        if ( $per_page > 0 ) {
            $comment_args['number'] = $per_page;

            $page = (int) get_query_var( 'cpage' );
            if ( $page ) {
                $comment_args['paged'] = $page;
            } elseif ( 'oldest' === $default_page ) {
                $comment_args['paged'] = 1;
            } elseif ( 'newest' === $default_page ) {
                $max_num_pages = (int) ( new WP_Comment_Query( $comment_args ) )->max_num_pages;
                if ( 0 !== $max_num_pages ) {
                    $comment_args['paged'] = $max_num_pages;
                }
            }
            // Set the `cpage` query var to ensure the previous and next pagination links are correct
'class'             => 'postform',
        'depth'             => 0,
        'tab_index'         => 0,
        'taxonomy'          => 'category',
        'hide_if_empty'     => false,
        'option_none_value' => -1,
        'value_field'       => 'term_id',
        'required'          => false,
        'aria_describedby'  => '',
    );

    $defaults['selected'] = ( is_category() ) ? get_query_var( 'cat' ) : 0;

    // Back compat.     if ( isset( $args['type'] ) && 'link' === $args['type'] ) {
        _deprecated_argument(
            __FUNCTION__,
            '3.0.0',
            sprintf(
                /* translators: 1: "type => link", 2: "taxonomy => link_category" */
                __( '%1$s is deprecated. Use %2$s instead.' ),
                '<code>type => link</code>',
                '<code>taxonomy => link_category</code>'
            )
$return = '';

    if ( ! is_singular() ) {
        $defaults = array(
            'sep'      => ' &#8212; ',
            'prelabel' => __( '&laquo; Previous Page' ),
            'nxtlabel' => __( 'Next Page &raquo;' ),
        );
        $args     = wp_parse_args( $args$defaults );

        $max_num_pages = $wp_query->max_num_pages;
        $paged         = get_query_var( 'paged' );

        // Only have sep if there's both prev and next results.         if ( $paged < 2 || $paged >= $max_num_pages ) {
            $args['sep'] = '';
        }

        if ( $max_num_pages > 1 ) {
            $return  = get_previous_posts_link( $args['prelabel'] );
            $return .= preg_replace( '/&([^#])(?![a-z]{1,8};)/i', '&#038;$1', $args['sep'] );
            $return .= get_next_posts_link( $args['nxtlabel'] );
        }
    }
// The posts page does not support the <!--nextpage--> pagination.             if ( $wp_query->is_posts_page && ! empty( $this->query_vars['page'] ) ) {
                $content_found = false;
            }

            if ( $content_found ) {
                $set_404 = false;
            }

            // We will 404 for paged queries, as no posts were found.         } elseif ( ! is_paged() ) {
            $author = get_query_var( 'author' );

            // Don't 404 for authors without posts as long as they matched an author on this site.             if ( is_author() && is_numeric( $author ) && $author > 0 && is_user_member_of_blog( $author )
                // Don't 404 for these queries if they matched an object.                 || ( is_tag() || is_category() || is_tax() || is_post_type_archive() ) && get_queried_object()
                // Don't 404 for these queries either.                 || is_home() || is_search() || is_feed()
            ) {
                $set_404 = false;
            }
        }

        
/** * Renders the `core/post-author` block on the server. * * @param array $attributes Block attributes. * @param string $content Block default content. * @param WP_Block $block Block instance. * @return string Returns the rendered author block. */
function render_block_core_post_author( $attributes$content$block ) {
    if ( ! isset( $block->context['postId'] ) ) {
        $author_id = get_query_var( 'author' );
    } else {
        $author_id = get_post_field( 'post_author', $block->context['postId'] );
    }

    if ( empty( $author_id ) ) {
        return '';
    }

    $avatar = ! empty( $attributes['avatarSize'] ) ? get_avatar(
        $author_id,
        $attributes['avatarSize']
    )


    if ( empty( $comments ) ) {
        return 0;
    }

    if ( ! get_option( 'page_comments' ) ) {
        return 1;
    }

    if ( ! isset( $per_page ) ) {
        $per_page = (int) get_query_var( 'comments_per_page' );
    }
    if ( 0 === $per_page ) {
        $per_page = (int) get_option( 'comments_per_page' );
    }
    if ( 0 === $per_page ) {
        return 1;
    }

    if ( ! isset( $threaded ) ) {
        $threaded = get_option( 'thread_comments' );
    }

    
'who'                     => '',
        'include_selected'        => false,
        'option_none_value'       => -1,
        'role'                    => '',
        'role__in'                => array(),
        'role__not_in'            => array(),
        'capability'              => '',
        'capability__in'          => array(),
        'capability__not_in'      => array(),
    );

    $defaults['selected'] = is_author() ? get_query_var( 'author' ) : 0;

    $parsed_args = wp_parse_args( $args$defaults );

    $query_args = wp_array_slice_assoc(
        $parsed_args,
        array(
            'blog_id',
            'include',
            'exclude',
            'orderby',
            'order',
            
/** * Renders sitemap templates based on rewrite rules. * * @since 5.5.0 * * @global WP_Query $wp_query WordPress Query object. */
    public function render_sitemaps() {
        global $wp_query;

        $sitemap         = sanitize_text_field( get_query_var( 'sitemap' ) );
        $object_subtype  = sanitize_text_field( get_query_var( 'sitemap-subtype' ) );
        $stylesheet_type = sanitize_text_field( get_query_var( 'sitemap-stylesheet' ) );
        $paged           = absint( get_query_var( 'paged' ) );

        // Bail early if this isn't a sitemap or stylesheet route.         if ( ! ( $sitemap || $stylesheet_type ) ) {
            return;
        }

        if ( ! $this->sitemaps_enabled() ) {
            $wp_query->set_404();
            

function get_archive_template() {
    $post_types = array_filter( (array) get_query_var( 'post_type' ) );

    $templates = array();

    if ( count( $post_types ) === 1 ) {
        $post_type   = reset( $post_types );
        $templates[] = "archive-{$post_type}.php";
    }
    $templates[] = 'archive.php';

    return get_query_template( 'archive', $templates );
}

$wp_query->the_comment();
}

/** * Redirect old slugs to the correct permalink. * * Attempts to find the current slug from the past slugs. * * @since 2.1.0 */
function wp_old_slug_redirect() {
    if ( is_404() && '' !== get_query_var( 'name' ) ) {
        // Guess the current post type based on the query vars.         if ( get_query_var( 'post_type' ) ) {
            $post_type = get_query_var( 'post_type' );
        } elseif ( get_query_var( 'attachment' ) ) {
            $post_type = 'attachment';
        } elseif ( get_query_var( 'pagename' ) ) {
            $post_type = 'page';
        } else {
            $post_type = 'post';
        }

        
Home | Imprint | This part of the site doesn't use cookies.