• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP set_query_var函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: limit_posts_per_archive_page

function limit_posts_per_archive_page()
{
    if (is_category(31)) {
        set_query_var('posts_per_archive_page', 5);
    }
    // or use variable key: posts_per_page
}
开发者ID:sleeping-lion,项目名称:dojisa,代码行数:7,代码来源:functions.php


示例2: index

 public function index($page = 1)
 {
     global $paged;
     $page_id = get_option('page_for_posts');
     if ($page < 0) {
         $page = 1;
     }
     set_query_var('paged', $page);
     if ($page_id > 0) {
         $layout = get_post_meta($page_id, '_layout', true);
         if (empty($layout) || !$this->view->check_layout($layout)) {
             $layout = $this->core->get_option('blog_layout', 'content_right');
         }
         $page_title = get_the_title($page_id);
         $page_tagline = get_post_meta($page_id, '_page_tagline', true);
         if (!get_post_meta($page_id, '_disable_page_title', true)) {
             $this->view->add_block('page_title', 'general/page_title', array('page_title' => $page_title, 'page_tagline' => $page_tagline));
         }
         if (!get_post_meta($page_id, '_disable_breadcrumbs', true)) {
             $this->breadcrumbs->add_item($page_title . ' ' . $page_tagline, get_permalink($page_id));
         }
     } else {
         // THEME SETTINGS
         $this->view->add_block('page_title', 'general/page_title', array('page_title' => $this->core->get_option('blog_title')));
         $layout = $this->core->get_option('blog_layout', 'content_right');
     }
     //$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
     $paginator = $this->load->library('paginator');
     $paginator = $paginator->get(3, wp_count_posts()->publish, get_option('posts_per_page'), 1, 2, 'blog/page/' . $page, 'blog/');
     $this->view->use_layout('header_' . $layout . '_footer')->add_block('content', 'blog/view', array('layout' => $layout))->add_block('content/pagination', 'general/pagination', $paginator);
 }
开发者ID:ashanrupasinghe,项目名称:amc-car-from-server-2015-1-14,代码行数:31,代码来源:blog.php


示例3: getLastPosts

    public function getLastPosts($atts)
    {
        extract(shortcode_atts(array('kategorie' => 'post', 'anzahl' => 3, 'zeichen' => 250), $atts));
        global $wpdb;
        $sql = 'SELECT p.ID, p.post_title, p.guid, p.post_content
				FROM ' . $wpdb->prefix . 'terms
					INNER JOIN ' . $wpdb->prefix . 'term_taxonomy ON ' . $wpdb->prefix . 'terms.term_id = ' . $wpdb->prefix . 'term_taxonomy.term_id
					INNER JOIN ' . $wpdb->prefix . 'term_relationships AS wpr ON wpr.term_taxonomy_id = ' . $wpdb->prefix . 'term_taxonomy.term_taxonomy_id
					INNER JOIN ' . $wpdb->prefix . 'posts AS p ON p.ID = wpr.object_id
				WHERE p.post_type = "post"
					AND ' . $wpdb->prefix . 'term_taxonomy.taxonomy = "category"
					AND ' . $wpdb->prefix . 'terms.name = "' . $kategorie . '"
					AND p.post_status = "publish"
				ORDER BY p.post_date
				DESC LIMIT ' . $anzahl;
        $result = $wpdb->get_results($sql);
        $lastPosts = array();
        if ($result) {
            foreach ($result as $key => $row) {
                if ((int) $zeichen === 0) {
                    $row->read_more = 0;
                } else {
                    $postContent = strip_tags($row->post_content);
                    //Alle HTML Tags entfernen. Nur reinen Text anzeigen lassen.
                    $row->post_content = substr($postContent, 0, $zeichen);
                    //Ausgabe begrenzen
                    $row->read_more = 1;
                }
                set_query_var('singlePost', $row);
                get_template_part('partials/single');
            }
        }
    }
开发者ID:JeffPlo,项目名称:skGruendau,代码行数:33,代码来源:CustomWebsite.php


示例4: render

    public function render($properties)
    {
        ?>
		<div class="module module--padded">



		<?php 
        $moduleIdentifier = "selectedModules_" . chr(rand(65, 90)) . chr(rand(65, 90)) . chr(rand(65, 90)) . chr(rand(65, 90)) . chr(rand(65, 90));
        $fagmod = new Fagmoduler();
        if (is_page_template('gode-erfaringer-children.php')) {
            $field_fornavn = get_field('fornavn', get_the_ID());
            if ($field_fornavn) {
                print '<h3>' . $properties['headline'] . ' som ' . $field_fornavn . '</h3>';
            } else {
                print '<h3>' . $properties['headline'] . '</h3>';
            }
        } else {
            print '<h2>' . $properties['headline'] . '</h2>';
        }
        $fagList = array();
        foreach ($properties['modules'] as $modul) {
            $fag = $fagmod->getFag(get_field("fag_id", $modul['module_post']->ID));
            $fagList[] = $fag;
        }
        ?>



		<script>
			var <?php 
        print $moduleIdentifier;
        ?>
 = <?php 
        print json_encode($fagList);
        ?>
;
		</script>
	
		<div class="accordion accordion--trade panel-group" ng-controller="SelectedModulesCtrl as <?php 
        print $moduleIdentifier;
        ?>
" ng-init="<?php 
        print $moduleIdentifier;
        ?>
.init('<?php 
        print $moduleIdentifier;
        ?>
')">
			<?php 
        set_query_var('moduleIdentifier', $moduleIdentifier);
        get_template_part('parts/fagmoduler-accordion-part');
        ?>
		</div>



		</div>
		<?php 
    }
开发者ID:jimmirbn,项目名称:mj-elteknik,代码行数:60,代码来源:SelectedModules.php


示例5: wp

 public function wp(WP $WP)
 {
     if (is_404() && ($class_name = $this->get_404_class_name())) {
     } elseif (is_search() && ($class_name = $this->get_search_class_name())) {
     } elseif (is_front_page() && ($class_name = $this->get_front_page_class_name())) {
     } elseif (is_home() && ($class_name = $this->get_home_class_name())) {
     } elseif (is_post_type_archive() && ($class_name = $this->get_post_type_archive_class_name())) {
     } elseif (is_tax() && ($class_name = $this->get_taxonomy_class_name())) {
         //        elseif (is_attachment() && $class_name = $this->get_attachment_class_name()):
     } elseif (is_page() && ($class_name = $this->get_page_class_name())) {
     } elseif (is_single() && ($class_name = $this->get_single_class_name())) {
     } elseif (is_category() && ($class_name = $this->get_category_class_name())) {
     } elseif (is_tag() && ($class_name = $this->get_tag_class_name())) {
     } elseif (is_author() && ($class_name = $this->get_author_class_name())) {
     } elseif (is_date() && ($class_name = $this->get_date_class_name())) {
         //        elseif (is_comments_popup() && $class_name = $this->get_comments_popup_class_name()):
         //        elseif (is_paged() && $class_name = $this->get_paged_class_name()):
     } else {
         $class_name = $this->get_index_class_name();
     }
     // must use Autoloader
     if ($class_name && class_exists($class_name)) {
         set_query_var($this->class_data['store_name'], new $class_name());
     }
     return;
 }
开发者ID:p-o-t-s,项目名称:wpsb-class-selector,代码行数:26,代码来源:WPsB_Class_Selector.php


示例6: changept

function changept()
{
    if (is_category() && !is_admin()) {
        set_query_var('post_type', array('post', 'category'));
    }
    return;
}
开发者ID:jonbrown21,项目名称:JBD-Wordpress-Theme,代码行数:7,代码来源:functions.php


示例7: Dashboard

 /**
  * @usage Short-code function for front-end UI
  * @return string
  */
 function Dashboard()
 {
     global $current_user;
     wp_reset_query();
     $currentAccess = maybe_unserialize(get_option('__wpdm_front_end_access', array()));
     $task = get_query_var('adb_page');
     $task = explode("/", $task);
     if ($task[0] == 'edit-package') {
         $pid = $task[1];
     }
     if ($task[0] == 'page') {
         $task[0] = '';
         set_query_var('paged', $task[1]);
     }
     $task = $task[0];
     if (!array_intersect($currentAccess, $current_user->roles) && is_user_logged_in()) {
         return "<div class='w3eden'><div class='alert alert-danger'>" . wpautop(stripslashes(get_option('__wpdm_front_end_access_blocked', __('Sorry, Your Are Not Allowed!', 'wpdmpro')))) . "</div></div>";
     }
     $id = wpdm_query_var('ID');
     $tabs = array();
     $tabs = apply_filters('wpdm_frontend', $tabs);
     $burl = get_permalink();
     $sap = strpos($burl, '?') ? '&' : '?';
     ob_start();
     include \WPDM\Template::Locate('author-dashboard.php');
     $data = ob_get_clean();
     return $data;
 }
开发者ID:bitflipper1,项目名称:ghcontracting,代码行数:32,代码来源:class.AuthorDashboard.php


示例8: process

 public static function process()
 {
     theme_features::check_referer();
     $post_id = isset($_GET['post-id']) && is_numeric($_GET['post-id']) ? (int) $_GET['post-id'] : false;
     if (!$post_id) {
         die(theme_features::json_format(['status' => 'error', 'code' => 'invaild_post_id', 'msg' => ___('Sorry, post id is invaild.')]));
     }
     global $post, $page;
     /**
      * post
      */
     $post = theme_cache::get_post($post_id);
     if (!$post) {
         die(theme_features::json_format(['status' => 'error', 'code' => 'post_not_exist', 'msg' => ___('Sorry, the post does not exist.')]));
     }
     /**
      * page
      */
     $page = isset($_GET['page']) && is_numeric($_GET['page']) ? (int) $_GET['page'] : false;
     if (!$page) {
         die(theme_features::json_format(['status' => 'error', 'code' => 'invaild_page_number', 'msg' => ___('Sorry, page number is invaild.')]));
     }
     set_query_var('page', $page);
     setup_postdata($post);
     ob_start();
     if (class_exists('theme_img_lazyload')) {
         remove_filter('the_content', 'theme_img_lazyload::the_content');
     }
     the_content();
     $content = html_minify(ob_get_contents());
     ob_end_clean();
     die(theme_features::json_format(['status' => 'success', 'content' => $content]));
 }
开发者ID:ClayMoreBoy,项目名称:mx,代码行数:33,代码来源:page-nagination-ajax.php


示例9: testThePosts

 public function testThePosts()
 {
     global $wp_query;
     $this->assertNull($this->frontend->thePosts(null));
     set_query_var('is_search', false);
     $posts = array();
     $posts[] = new WP_Post();
     $posts[] = new WP_Post();
     $this->assertEquals($this->frontend->thePosts($posts), $posts);
     set_query_var('is_search', true);
     set_query_var('is_admin', true);
     $this->assertEquals($this->frontend->thePosts($posts), $posts);
     set_query_var('is_search', true);
     set_query_var('is_admin', false);
     $this->assertNotEquals($this->frontend->thePosts($posts), $posts);
     $post = new WP_Post();
     $post->ID = 3;
     $posts = array($post);
     set_query_var('is_main_query', true);
     $wp_query->is_main_query = true;
     $wp_query->is_search = true;
     $wp_query->is_admin = false;
     $wp_query->query['s'] = 'aliyun';
     $this->aliyunOpenSearchClient->shouldReceive('search')->andReturn(array('posts' => $posts, 'total' => 1))->once();
     $this->frontend->preGetPosts($wp_query);
     $this->assertEquals($this->frontend->thePosts($posts), $posts);
 }
开发者ID:mr5,项目名称:aliyun-opensearch,代码行数:27,代码来源:AliyunOpenSearchFrontendTest.php


示例10: display

    /**
     * Display related posts
     */
    public function display()
    {
        $posts = $this->get_related_posts();
        if (empty($posts)) {
            return;
        }
        global $post, $wp_query;
        $default_query = clone $wp_query;
        set_query_var('is_related', true);
        ?>
		<div class="related-posts">
			<h2 class="related-posts__title h3"><?php 
        _e('Related posts', 'habakiri');
        ?>
</h2>
			<div class="entries entries--related-posts entries-related-posts">
				<?php 
        foreach ($posts as $post) {
            setup_postdata($post);
            get_template_part('content', 'summary');
        }
        wp_reset_postdata();
        ?>
			</div>
		</div>
		<?php 
        $wp_query = $default_query;
    }
开发者ID:ConductiveIO,项目名称:mbrady,代码行数:31,代码来源:class.related-posts.php


示例11: nimbus_cotizador

function nimbus_cotizador($atts, $content)
{
    extract($atts);
    set_query_var('success', $action);
    $template = locate_template("/templates/quote.php");
    load_template($template);
}
开发者ID:ricardomangore,项目名称:nimbus,代码行数:7,代码来源:nimbus_short_codes.php


示例12: spun_limit_posts_per_archive_page

/**
 * Filter archives to display one less post per page to account for the .page-title circle
 */
function spun_limit_posts_per_archive_page()
{
    if (!is_home() && is_archive() || is_search()) {
        $posts_per_page = intval(get_option('posts_per_page')) - 1;
        set_query_var('posts_per_page', $posts_per_page);
    }
}
开发者ID:sudocoda,项目名称:ekiben,代码行数:10,代码来源:extras.php


示例13: wpex_blog_exclude_categories

 function wpex_blog_exclude_categories()
 {
     // Wait..we don't want to be in these plages? Lets leave now!
     if (is_admin()) {
         return;
     }
     if (is_search()) {
         return;
     }
     if (is_archive()) {
         return;
     }
     // Categories to exclude
     $cats_to_exclude = wpex_option('blog_cats_exclude');
     // Admin option is blank, so bail.
     if ($cats_to_exclude == '') {
         return;
     }
     // Blog template
     if (is_home() && !is_singular('page')) {
         $exclude = $cats_to_exclude;
     } else {
         return;
         // Do nothing, ok?
     }
     if ($cats_to_exclude) {
         set_query_var('category__not_in', $cats_to_exclude);
     }
 }
开发者ID:nhatnam1102,项目名称:wp-content,代码行数:29,代码来源:blog-exclude-categories.php


示例14: widget

 function widget($args, $instance)
 {
     // Turn $args array into variables.
     extract($args);
     // $instance Defaults
     $instance_defaults = $this->defaults;
     // Parse $instance
     $instance = wp_parse_args($instance, $instance_defaults);
     // Options output
     $section_title = !empty($instance['title']) ? $instance['title'] : '';
     set_query_var('section_title', strip_tags($section_title));
     $spo = !empty($instance['show_pos']) ? 1 : 0;
     set_query_var('spo', absint($spo));
     $sco = !empty($instance['show_com']) ? 1 : 0;
     set_query_var('sco', absint($sco));
     $sca = !empty($instance['show_cat']) ? 1 : 0;
     set_query_var('sca', absint($sca));
     $sda = !empty($instance['show_date']) ? 1 : 0;
     set_query_var('sda', absint($sda));
     $cnmt = !empty($instance['css_no_mt']) ? 1 : 0;
     $cnmb = !empty($instance['css_no_mb']) ? 1 : 0;
     $cbot = !empty($instance['css_b_top']) ? 1 : 0;
     $cbob = !empty($instance['css_b_bot']) ? 1 : 0;
     $cpat = !empty($instance['css_p_top']) ? 1 : 0;
     // Widget styling based on options
     $css_class = array();
     if ($cnmt) {
         $css_class[] = 'n-mt';
     }
     if ($cnmb) {
         $css_class[] = 'n-mb';
     }
     if ($cbot) {
         $css_class[] = 'b-top';
     }
     if ($cbob) {
         $css_class[] = 'b-bot';
     }
     if ($cpat) {
         $css_class[] = 'p-top';
     }
     $css_classes = join(' ', $css_class);
     if (!empty($css_classes)) {
         if (strpos($args['before_widget'], 'class') === false) {
             $args['before_widget'] = str_replace('>', 'class="' . esc_attr($css_classes) . '"', $args['before_widget']);
         } else {
             $args['before_widget'] = str_replace('class="', 'class="' . esc_attr($css_classes) . ' ', $args['before_widget']);
         }
     }
     // Output
     echo $args['before_widget'];
     // Before widget template
     // Section template
     get_template_part('section-templates/section', 'popular-posts');
     // Get section template
     echo $args['after_widget'];
     // After widget template
 }
开发者ID:jimdough,项目名称:Roadmaster,代码行数:58,代码来源:section-popular-posts-widget.php


示例15: test_canonical

 /**
  * @covers WPSEO_Sitemaps::canonical
  */
 public function test_canonical()
 {
     $url = site_url();
     $this->assertNotEmpty(self::$class_instance->canonical($url));
     set_query_var('sitemap', 'sitemap_value');
     $this->assertFalse(self::$class_instance->canonical($url));
     set_query_var('xsl', 'xsl_value');
     $this->assertFalse(self::$class_instance->canonical($url));
 }
开发者ID:centre-for-effective-altruism,项目名称:wordpress-seo,代码行数:12,代码来源:test-class-wpseo-sitemaps.php


示例16: usp_addSubmittedStatusClause

function usp_addSubmittedStatusClause($wp_query)
{
    global $pagenow, $usp_post_meta_IsSubmission;
    if (is_admin() && $pagenow == 'edit.php' && $_GET['user_submitted'] == '1') {
        set_query_var('meta_key', $usp_post_meta_IsSubmission);
        set_query_var('meta_value', 1);
        set_query_var('post_status', 'pending');
    }
}
开发者ID:juslee,项目名称:e27,代码行数:9,代码来源:user-submitted-posts.php


示例17: theme_exclude_category_feed

function theme_exclude_category_feed()
{
    $exclude_cats = theme_get_option('blog', 'exclude_categorys');
    foreach ($exclude_cats as $key => $cat) {
        $exclude_cats[$key] = -$cat;
    }
    if (is_feed()) {
        set_query_var("cat", implode(",", $exclude_cats));
    }
}
开发者ID:blocher,项目名称:oneholyname,代码行数:10,代码来源:filter.php


示例18: setVar

 /**
  * Set query variable in the WP_Query class.
  *
  * Wrapper method for the WordPress core `set_query_var()` function. This is a work around for theme's and plugins
  * which break the WordPress global $wp_query var by unsetting it or overwriting it which break the method call
  * that `set_query_var()` uses to set the query variable.
  *
  * @access public
  * @since  8.5.14
  *
  * @global WP_Query $wp_query Global WP_Query instance.
  *
  * @param string $var   Query variable key.
  * @param mixed  $value Query variable value.
  */
 public static function setVar($var, $value)
 {
     global $wp_query;
     if (is_a($wp_query, 'WP_Query') && is_callable(array($wp_query, 'get'))) {
         set_query_var($var, $value);
     } else {
         $GLOBALS['wp_query']->query_vars[$var] = $value;
         $GLOBALS['wp_the_query']->query_vars[$var] = $value;
     }
 }
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:25,代码来源:class.query.php


示例19: test_page_should_default_to_1_when_no_cpage_query_var_is_found

 /**
  * @ticket 20319
  */
 public function test_page_should_default_to_1_when_no_cpage_query_var_is_found()
 {
     $p = self::factory()->post->create();
     $this->go_to(get_permalink($p));
     $cpage = get_query_var('cpage');
     set_query_var('cpage', '');
     $link = get_next_comments_link('Next', 5);
     $this->assertContains('cpage=2', $link);
     set_query_var('cpage', $cpage);
 }
开发者ID:boonebgorges,项目名称:develop.wordpress,代码行数:13,代码来源:getNextCommentsLink.php


示例20: loadReadMore

 public function loadReadMore($url, $display_type, $entityId, $readmore)
 {
     load_plugin_textdomain('sociallymap', false, '../' . basename(dirname(__FILE__)));
     set_query_var('data', ['url' => $url, 'display_type' => $display_type, 'entityId' => $entityId, 'readmore' => $readmore]);
     ob_start();
     load_template($this->urlBase . 'readmore-template.php', false);
     $readmore = ob_get_contents();
     ob_end_clean();
     return $readmore;
 }
开发者ID:alhenaconseil,项目名称:wordpress-sociallymap,代码行数:10,代码来源:Templater.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP set_radio函数代码示例发布时间:2022-05-15
下一篇:
PHP set_profile_field函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap