当前位置: 首页>>代码示例>>PHP>>正文


PHP get_query_var函数代码示例

本文整理汇总了PHP中get_query_var函数的典型用法代码示例。如果您正苦于以下问题:PHP get_query_var函数的具体用法?PHP get_query_var怎么用?PHP get_query_var使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_query_var函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: wp_corenavi

function wp_corenavi()
{
    global $wp_query;
    $pages = '';
    $max = $wp_query->max_num_pages;
    if (!($current = get_query_var('paged'))) {
        $current = 1;
    }
    $a['base'] = str_replace(999999999, '%#%', get_pagenum_link(999999999));
    $a['total'] = $max;
    $a['current'] = $current;
    $total = 1;
    //1 - выводить текст "Страница N из N", 0 - не выводить
    $a['mid_size'] = 3;
    //сколько ссылок показывать слева и справа от текущей
    $a['end_size'] = 1;
    //сколько ссылок показывать в начале и в конце
    $a['prev_text'] = '«';
    //текст ссылки "Предыдущая страница"
    $a['next_text'] = '»';
    //текст ссылки "Следующая страница"
    if ($max > 1) {
        echo '<div class="navigation">';
    }
    if ($total == 1 && $max > 1) {
        $pages = '<span class="pages">Страница ' . $current . ' из ' . $max . '</span>' . "\r\n";
    }
    echo $pages . paginate_links($a);
    if ($max > 1) {
        echo '</div>';
    }
}
开发者ID:king199025,项目名称:Fox-Kids,代码行数:32,代码来源:functions.php

示例2: bap_ajaxP_loop

function bap_ajaxP_loop($offset = '')
{
    global $wp_query;
    $paged = get_query_var('page') ? get_query_var('page') : 1;
    $do_not_duplicate = array();
    // OFFSET SETTING
    if (!$offset == '' || !$offset == '0') {
        $argshidepost = array('numberposts' => $offset, 'post_type' => 'post', 'post_status' => 'publish');
        $hide_to_array = get_posts($argshidepost);
        // HIDE OFFSETED POSTS
        if ($hide_to_array) {
            foreach ($hide_to_array as $post) {
                $do_not_duplicate[] = $post->ID;
            }
        }
    }
    $argsmain = array('post_type' => 'post', 'post_status' => 'publish', 'paged' => $paged, 'order' => 'DESC', 'post__not_in' => $do_not_duplicate);
    $wp_query = new WP_Query($argsmain);
    if ($wp_query->have_posts()) {
        echo '<section id="' . bap_get_option_text('bap_loopContainer') . '">';
        while ($wp_query->have_posts()) {
            $wp_query->the_post();
            get_template_part('partials/listitem');
        }
        echo '</section>';
    }
    wp_reset_postdata();
}
开发者ID:Aventyret,项目名称:bentoWP_plugin_AjaxPagin,代码行数:28,代码来源:bap_functions.php

示例3: farmtoyou_paging_nav

    /**
     * Display navigation to next/previous set of posts when applicable.
     *
     * @since Farmtoyou 1.0
     *
     * @global WP_Query   $wp_query   WordPress Query object.
     * @global WP_Rewrite $wp_rewrite WordPress Rewrite object.
     */
    function farmtoyou_paging_nav()
    {
        global $wp_query, $wp_rewrite;
        // Don't print empty markup if there's only one page.
        if ($wp_query->max_num_pages < 2) {
            return;
        }
        $paged = get_query_var('paged') ? intval(get_query_var('paged')) : 1;
        $pagenum_link = html_entity_decode(get_pagenum_link());
        $query_args = array();
        $url_parts = explode('?', $pagenum_link);
        if (isset($url_parts[1])) {
            wp_parse_str($url_parts[1], $query_args);
        }
        $pagenum_link = remove_query_arg(array_keys($query_args), $pagenum_link);
        $pagenum_link = trailingslashit($pagenum_link) . '%_%';
        $format = $wp_rewrite->using_index_permalinks() && !strpos($pagenum_link, 'index.php') ? 'index.php/' : '';
        $format .= $wp_rewrite->using_permalinks() ? user_trailingslashit($wp_rewrite->pagination_base . '/%#%', 'paged') : '?paged=%#%';
        // Set up paginated links.
        $links = paginate_links(array('base' => $pagenum_link, 'format' => $format, 'total' => $wp_query->max_num_pages, 'current' => $paged, 'mid_size' => 1, 'add_args' => array_map('urlencode', $query_args), 'prev_text' => __('&larr; Previous', 'farmtoyou'), 'next_text' => __('Next &rarr;', 'farmtoyou')));
        if ($links) {
            ?>
	<nav class="navigation paging-navigation" role="navigation">
		<div class="pagination loop-pagination">
			<?php 
            echo $links;
            ?>
		</div><!-- .pagination -->
	</nav><!-- .navigation -->
	<?php 
        }
    }
开发者ID:abcode619,项目名称:wpstuff,代码行数:40,代码来源:template-tags.php

示例4: page_navi

function page_navi($before = '', $after = '')
{
    global $wpdb, $wp_query;
    $request = $wp_query->request;
    $posts_per_page = intval(get_query_var('posts_per_page'));
    $paged = intval(get_query_var('paged'));
    $numposts = $wp_query->found_posts;
    $max_page = $wp_query->max_num_pages;
    if ($numposts <= $posts_per_page) {
        return;
    }
    if (empty($paged) || $paged == 0) {
        $paged = 1;
    }
    $pages_to_show = 3;
    $pages_to_show_minus_1 = $pages_to_show - 1;
    $half_page_start = floor($pages_to_show_minus_1 / 2);
    $half_page_end = ceil($pages_to_show_minus_1 / 2);
    $start_page = $paged - $half_page_start;
    if ($start_page <= 0) {
        $start_page = 1;
    }
    $end_page = $paged + $half_page_end;
    if ($end_page - $start_page != $pages_to_show_minus_1) {
        $end_page = $start_page + $pages_to_show_minus_1;
    }
    if ($end_page > $max_page) {
        $start_page = $max_page - $pages_to_show_minus_1;
        $end_page = $max_page;
    }
    if ($start_page <= 0) {
        $start_page = 1;
    }
    echo $before . '<div class="pagination_wrapper"><ul class="pagination">' . "";
    if ($paged > 1) {
        $first_page_text = "First";
        echo '<li class="prev"><a href="' . get_pagenum_link() . '" title="First">' . $first_page_text . '</a></li>';
    }
    $prevposts = get_previous_posts_link('Prev');
    if ($prevposts) {
        echo '<li>' . $prevposts . '</li>';
    } else {
        echo '<li class="disabled"><a href="#">Prev</a></li>';
    }
    for ($i = $start_page; $i <= $end_page; $i++) {
        if ($i == $paged) {
            echo '<li class="active"><a href="#">' . $i . '</a></li>';
        } else {
            echo '<li><a href="' . get_pagenum_link($i) . '">' . $i . '</a></li>';
        }
    }
    if ($end_page < $max_page) {
        $last_page_text = $max_page;
        echo '<li class="next"><a href="' . get_pagenum_link($max_page) . '" title="Last">' . $last_page_text . '</a></li>';
    }
    echo '<li class="">';
    next_posts_link('Next');
    echo '</li>';
    echo '</ul></div>' . $after . "";
}
开发者ID:madeloa,项目名称:holmesdev,代码行数:60,代码来源:pagination.php

示例5: parse_query

 /**
  * Hook into the query parsing to detect oEmbed requests.
  *
  * If an oEmbed request is made, trigger the output.
  *
  * @codeCoverageIgnore
  *
  * @param WP_Query $wp_query The WP_Query instance (passed by reference).
  */
 public function parse_query($wp_query)
 {
     // Check for required params.
     if (false === $wp_query->get('oembed', false)) {
         return;
     }
     if (false === $wp_query->get('url', false)) {
         status_header(400);
         echo 'URL parameter missing';
         exit;
     }
     /**
      * Check for the allowed query vars and set defaults.
      *
      * @see WP_REST_oEmbed_Controller::register_routes()
      */
     $url = esc_url_raw(get_query_var('url'));
     $format = sanitize_text_field(get_query_var('format', 'json'));
     /**
      * Filter the maxwidth oEmbed parameter.
      *
      * @param int $maxwidth Maximum allowed width. Defaults to 600.
      *
      * @return int
      */
     $maxwidth = apply_filters('oembed_default_width', 600);
     $maxwidth = get_query_var('maxwidth', $maxwidth);
     $callback = get_query_var('_jsonp', false);
     $request = array('url' => $url, 'format' => $format, 'maxwidth' => $maxwidth, 'callback' => $callback);
     echo $this->dispatch($request);
     exit;
 }
开发者ID:noplanman,项目名称:oEmbed-API,代码行数:41,代码来源:class-wp-legacy-oembed-controller.php

示例6: pagination

 public function pagination($total = -1, $spread = -1)
 {
     global $wp_query;
     $big = 999999999;
     // need an unlikely integer
     $current = max(1, get_query_var('paged'));
     if ($total < 1) {
         $total = $wp_query->max_num_pages;
     }
     if ($spread < 1) {
         $spread = self::DEFAULT_PAGINATION_SPREAD;
     }
     $spread_left = min($current - 1, $spread * 2);
     $spread_right = min($current + $spread * 2, $total) - $current;
     if ($spread_left + $spread_right > 4) {
         if ($spread_left >= 2 && $spread_right >= 2) {
             $spread_left = $spread_right = 2;
         } elseif ($spread_left < 2) {
             $spread_right = 4 - $spread_left;
         } else {
             $spread_left = 4 - $spread_right;
         }
     }
     $pages = range($current - $spread_left, $current + $spread_right);
     $links = array_map(function ($n) use($current) {
         return '<li>' . ($n == $current ? "<span>{$current}</span>" : sprintf('<a href="%s">%s</a>', get_pagenum_link($n), $n)) . '</li>';
     }, $pages);
     $out = '<nav class="pagination">';
     $out .= sprintf('<a class="edge edge--left" href="%s">First</a>', get_pagenum_link(1));
     $out .= sprintf('<ul class="nav-menu">%s</ul>', implode('', $links));
     $out .= sprintf('<a class="edge edge--right" href="%s">Last</a>', get_pagenum_link($total));
     $out = '</nav>';
     return $out;
 }
开发者ID:elpadi,项目名称:wordpress-library,代码行数:34,代码来源:PaginationTrait.php

示例7: expose_homepage_post_class

function expose_homepage_post_class($classes)
{
    global $loop_counter;
    $paged = get_query_var('paged') ? get_query_var('paged') : 1;
    $classes[] = 'portfolio-posts';
    return $classes;
}
开发者ID:nmrugg,项目名称:studiopress-premum-wp-themes,代码行数:7,代码来源:home.php

示例8: stachestack_title

/**
 * Page titles
 */
function stachestack_title()
{
    if (is_home()) {
        if (get_option('page_for_posts', true)) {
            $title = get_the_title(get_option('page_for_posts', true));
        } else {
            $title = __('Latest Posts', 'stachestack');
        }
    } elseif (is_archive()) {
        $term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
        if ($term) {
            $title = apply_filters('single_term_title', $term->name);
        } elseif (is_post_type_archive()) {
            $title = apply_filters('the_title', get_queried_object()->labels->name);
        } elseif (is_day()) {
            $title = sprintf(__('Daily Archives: %s', 'stachestack'), get_the_date());
        } elseif (is_month()) {
            $title = sprintf(__('Monthly Archives: %s', 'stachestack'), get_the_date('F Y'));
        } elseif (is_year()) {
            $title = sprintf(__('Yearly Archives: %s', 'stachestack'), get_the_date('Y'));
        } elseif (is_author()) {
            $title = sprintf(__('Author Archives: %s', 'stachestack'), get_queried_object()->display_name);
        } else {
            $title = single_cat_title('', false);
        }
    } elseif (is_search()) {
        $title = sprintf(__('Search Results for %s', 'stachestack'), get_search_query());
    } elseif (is_404()) {
        $title = __('Not Found', 'stachestack');
    } else {
        $title = get_the_title();
    }
    return apply_filters('stachestack_title', $title);
}
开发者ID:BeardandFedora,项目名称:StacheStack,代码行数:37,代码来源:titles.php

示例9: roots_nice_search_redirect

function roots_nice_search_redirect()
{
    if (is_search() && strpos($_SERVER['REQUEST_URI'], '/wp-admin/') === false && strpos($_SERVER['REQUEST_URI'], '/search/') === false) {
        wp_redirect(home_url('/search/' . str_replace(array(' ', '%20'), array('+', '+'), get_query_var('s'))));
        exit;
    }
}
开发者ID:herrhaase,项目名称:roots,代码行数:7,代码来源:roots-cleanup.php

示例10: my_simone_paging_nav

    /**
     * Display navigation to next/previous set of posts when applicable.
     *
     * @return void
     */
    function my_simone_paging_nav()
    {
        // Don't print empty markup if there's only one page.
        if ($GLOBALS['wp_query']->max_num_pages < 2) {
            return;
        }
        $paged = get_query_var('paged') ? intval(get_query_var('paged')) : 1;
        $pagenum_link = html_entity_decode(get_pagenum_link());
        $query_args = array();
        $url_parts = explode('?', $pagenum_link);
        if (isset($url_parts[1])) {
            wp_parse_str($url_parts[1], $query_args);
        }
        $pagenum_link = remove_query_arg(array_keys($query_args), $pagenum_link);
        $pagenum_link = trailingslashit($pagenum_link) . '%_%';
        $format = $GLOBALS['wp_rewrite']->using_index_permalinks() && !strpos($pagenum_link, 'index.php') ? 'index.php/' : '';
        $format .= $GLOBALS['wp_rewrite']->using_permalinks() ? user_trailingslashit('page/%#%', 'paged') : '?paged=%#%';
        // Set up paginated links.
        $links = paginate_links(array('base' => $pagenum_link, 'format' => $format, 'total' => $GLOBALS['wp_query']->max_num_pages, 'current' => $paged, 'mid_size' => 2, 'add_args' => array_map('urlencode', $query_args), 'prev_text' => __('← Previous', 'my-simone'), 'next_text' => __('Next →', 'my-simone'), 'type' => 'list'));
        if ($links) {
            ?>
	<nav class="navigation paging-navigation" role="navigation">
		<h1 class="screen-reader-text"><?php 
            _e('Posts navigation', 'my-simone');
            ?>
</h1>
			<?php 
            echo $links;
            ?>
	</nav><!-- .navigation -->
	<?php 
        }
    }
开发者ID:sintija,项目名称:wordpress_backup,代码行数:38,代码来源:template-tags.php

示例11: process_query_args

 /**
  * Handle any query args that come from the requested URL.
  *
  * @access protected
  *
  * @param  mixed $query Query string.
  * @return array Query arguments
  */
 protected function process_query_args($query)
 {
     // Handle requests for paged events.
     $paged = get_query_var('paged');
     if (2 <= $paged) {
         $query['paged'] = $paged;
     }
     // Filter by organizer ID if an "author archive" (organizer events) was requested.
     $organizer_id = get_query_var('organizer_id');
     if (empty($query['organizer_id']) && !empty($organizer_id)) {
         $query['organizer_id'] = (int) $organizer_id;
     }
     // Filter by venue ID if a venue archive (all events at a certain venue) was requested.
     $venue_id = get_query_var('venue_id');
     if (empty($query['venue_id']) && !empty($venue_id)) {
         $query['venue_id'] = (int) $venue_id;
     }
     // Filter by category ID if a category archive (all events in a certain category) was requested.
     $category_id = get_query_var('category_id');
     if (empty($query['category_id']) && !empty($category_id)) {
         $query['category_id'] = (int) $category_id;
     }
     // Filter by subcategory ID if a subcategory archive (all events in a certain subcategory) was requested.
     $subcategory_id = get_query_var('subcategory_id');
     if (empty($query['subcategory_id']) && !empty($subcategory_id)) {
         $query['subcategory_id'] = (int) $subcategory_id;
     }
     // Filter by format ID if a format archive (all events in a certain format) was requested.
     $format_id = get_query_var('format_id');
     if (empty($query['format_id']) && !empty($format_id)) {
         $query['format_id'] = (int) $format_id;
     }
     return $query;
 }
开发者ID:eb-jeffrey,项目名称:eventbrite-api,代码行数:42,代码来源:class-eventbrite-query.php

示例12: ktz_mustread_content

 function ktz_mustread_content()
 {
     global $post;
     if (ot_get_option('ktz_popup_activated') == 'yes') {
         $paged = get_query_var('paged') ? get_query_var('paged') : 1;
         $args = array('post_type' => 'post', 'orderby' => 'rand', 'order' => 'desc', 'showposts' => 3, 'post_status' => 'publish', 'ignore_sticky_posts' => 1);
         $ktz_topfeatquery = new WP_Query($args);
         if ($ktz_topfeatquery->have_posts()) {
             echo '<div id="ktz_slidebox">';
             echo '<strong class="mustread_title">' . __('Must read', ktz_theme_textdomain) . '</strong><a href="#" class="close">&times;</a>';
             echo '<ul class="mustread_list">';
             while ($ktz_topfeatquery->have_posts()) {
                 $ktz_topfeatquery->the_post();
                 echo '<li class="mustread_li clearfix">';
                 echo '<div class="pull-left">';
                 echo ktz_featured_img(50, 50);
                 echo '</div>';
                 echo '<div class="title">';
                 echo ktz_posted_title_a();
                 echo '</div>';
                 echo '</li>';
             }
             echo '</ul>';
             echo '</div>';
         }
         wp_reset_query();
     }
 }
开发者ID:jjpango,项目名称:JJTeam,代码行数:28,代码来源:_slider_ktz.php

示例13: roots_search_query

function roots_search_query($escaped = true) {
  $query = apply_filters('roots_search_query', get_query_var('s'));
  if ($escaped) {
      $query = esc_attr($query);
  }
  return urldecode($query);
}
开发者ID:ndimatteo,项目名称:kaiser-compare,代码行数:7,代码来源:roots-cleanup.php

示例14: bg_welcome_message

function bg_welcome_message()
{
    if (!is_front_page() || get_query_var('paged') >= 2) {
        return;
    }
    genesis_widget_area('welcome-message', array('before' => '<div class="welcome-message"><div class="wrap">', 'after' => '</div></div>'));
}
开发者ID:bgardner,项目名称:bg-shangri-la,代码行数:7,代码来源:functions.php

示例15: __construct

 /**
  * Initialize class
  * @param array $args Query arguments.
  * @access public
  * @since  2.0
  */
 public function __construct($args = array())
 {
     global $answers;
     $paged = get_query_var('paged') ? get_query_var('paged') : 1;
     $defaults = array('question_id' => get_question_id(), 'ap_answers_query' => true, 'showposts' => ap_opt('answers_per_page'), 'paged' => $paged, 'only_best_answer' => false, 'include_best_answer' => false);
     $args['post_status'][] = 'publish';
     $args['post_status'][] = 'closed';
     $this->args = wp_parse_args($args, $defaults);
     if (isset($this->args['question_id'])) {
         $question_id = $this->args['question_id'];
     }
     if (!empty($question_id)) {
         $this->args['post_parent'] = $question_id;
     }
     if (isset($this->args['sortby'])) {
         $this->orderby_answers();
     }
     // Check if requesting only for best Answer
     if (isset($this->args['only_best_answer']) && $this->args['only_best_answer']) {
         $this->args['meta_query'] = array(array('key' => ANSPRESS_BEST_META, 'type' => 'BOOLEAN', 'compare' => '=', 'value' => '1'));
     }
     $this->args['post_type'] = 'answer';
     $args = $this->args;
     /**
      * Initialize parent class
      */
     parent::__construct($args);
 }
开发者ID:troe,项目名称:anspress,代码行数:34,代码来源:answer-loop.php


注:本文中的get_query_var函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。