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


PHP Timber::query_posts方法代码示例

本文整理汇总了PHP中Timber::query_posts方法的典型用法代码示例。如果您正苦于以下问题:PHP Timber::query_posts方法的具体用法?PHP Timber::query_posts怎么用?PHP Timber::query_posts使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Timber的用法示例。


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

示例1: context

 /**
  * Determine the context that will be used by the content() method
  */
 public function context()
 {
     global $wp_query;
     $context = Maera()->cache->get_context();
     $post = new TimberPost();
     $context['post'] = $post;
     $context['posts'] = Timber::get_posts();
     // Compatibility hack or plugins that change the content.
     if ($this->plugins_compatibility()) {
         $context['content'] = maera_get_echo('the_content');
     }
     if (is_singular()) {
         $context['wp_title'] .= ' - ' . $post->title();
     }
     if (is_search()) {
         $context['title'] = __('Search results for ', 'maera') . get_search_query();
     }
     if (is_archive() || is_home()) {
         $context['posts'] = Timber::query_posts(false, 'TimberPost');
         $context['title'] = get_the_archive_title();
         if (is_author()) {
             $author = new TimberUser($wp_query->query_vars['author']);
             $context['author'] = $author;
         }
     }
     if (class_exists('WooCommerce')) {
         global $product;
         $context['product'] = $product;
     }
     return $context;
 }
开发者ID:wpmu,项目名称:maera,代码行数:34,代码来源:class-maera-template.php

示例2: get_context

 /**
  * Get context.
  *
  * @return array
  */
 public static function get_context()
 {
     $data = array();
     $data['http_host'] = 'http://' . TimberURLHelper::get_host();
     $data['wp_title'] = TimberHelper::get_wp_title();
     $data['wp_head'] = TimberHelper::function_wrapper('wp_head');
     $data['wp_footer'] = TimberHelper::function_wrapper('wp_footer');
     $data['body_class'] = implode(' ', get_body_class());
     $data['site'] = new TimberSite();
     $data['theme'] = $data['site']->theme;
     //deprecated, these should be fetched via TimberSite or TimberTheme
     $data['theme_dir'] = WP_CONTENT_SUBDIR . str_replace(WP_CONTENT_DIR, '', get_stylesheet_directory());
     $data['language_attributes'] = TimberHelper::function_wrapper('language_attributes');
     $data['stylesheet_uri'] = get_stylesheet_uri();
     $data['template_uri'] = get_template_directory_uri();
     $data['posts'] = Timber::query_posts();
     //deprecated, this should be fetched via TimberMenu
     if (function_exists('wp_nav_menu')) {
         $locations = get_nav_menu_locations();
         if (count($locations)) {
             $data['wp_nav_menu'] = wp_nav_menu(array('container_class' => 'menu-header', 'echo' => false, 'menu_class' => 'nav-menu'));
         }
     }
     $data = apply_filters('timber_context', $data);
     $data = apply_filters('timber/context', $data);
     return $data;
 }
开发者ID:Butterwell,项目名称:timber,代码行数:32,代码来源:timber.php

示例3: get_context

 /**
  * Get context.
  *
  * @return array
  */
 public static function get_context()
 {
     $data = array();
     $data['http_host'] = 'http://' . TimberURLHelper::get_host();
     $data['wp_title'] = TimberHelper::get_wp_title();
     $data['wp_head'] = TimberHelper::function_wrapper('wp_head');
     $data['wp_footer'] = TimberHelper::function_wrapper('wp_footer');
     $data['body_class'] = implode(' ', get_body_class());
     $data['site'] = new TimberSite();
     $data['theme'] = $data['site']->theme;
     $data['posts'] = Timber::query_posts();
     $data = apply_filters('timber_context', $data);
     $data = apply_filters('timber/context', $data);
     return $data;
 }
开发者ID:ruscon,项目名称:timber,代码行数:20,代码来源:timber.php

示例4: Maera

<?php

/**
* The template for displaying Archive pages.
*
* Used to display archive-type pages if nothing more specific matches a query.
* For example, puts together date-based pages if no date.php file exists.
*
* Learn more: http://codex.wordpress.org/Template_Hierarchy
*/
global $wp_query;
$data = Maera()->template->context();
$data['title'] = __('Downloads', 'maera_edd');
$data['posts'] = Timber::query_posts(false, 'TimberPost');
$data['query'] = $wp_query->query_vars;
// The in-cart class
$data['in_cart'] = function_exists('edd_item_in_cart') && edd_item_in_cart($post->ID) && !edd_has_variable_prices($post->ID) ? 'in-cart' : '';
// The variable-priced class
$data['variable_priced'] = function_exists('edd_has_variable_prices') && edd_has_variable_prices($post->ID) ? 'variable-priced' : '';
// Get a list with categories of each download (Isotope filtering)
$terms = get_the_terms($post->ID, 'download_category');
if ($terms && !is_wp_error($terms)) {
    foreach ($terms as $term) {
        $download_categories[] = $term->slug;
    }
    $data['categories'] = join(' ', $download_categories);
} else {
    $data['categories'] = '';
}
// Get a list with tags of each download (Isotope filtering)
$terms = get_the_terms($post->ID, 'download_tag');
开发者ID:wpmu,项目名称:maera,代码行数:31,代码来源:archive-download.php


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