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


PHP Timber::get_post方法代码示例

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


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

示例1: get_post

 /**
  * get_post
  *
  * @return mixed
  */
 protected function get_post()
 {
     if (empty($this->post)) {
         $this->post = \Timber::get_post();
     }
     return $this->post;
 }
开发者ID:benedict-w,项目名称:pressgang,代码行数:12,代码来源:page-controller.php

示例2: testCommentCountZero

 function testCommentCountZero()
 {
     $quote = 'Named must your fear be before banish it you can.';
     $post_id = $this->factory->post->create(array('post_content' => $quote));
     $post = Timber::get_post($post_id);
     $this->assertEquals(0, $post->get_comment_count());
 }
开发者ID:gwafork,项目名称:timber,代码行数:7,代码来源:test-timber-post-comments.php

示例3: testGetPostsFromSlug

 function testGetPostsFromSlug()
 {
     $post_id = $this->factory->post->create();
     $post = Timber::get_post($post_id);
     $str = $post->post_name;
     $post = Timber::get_post($str);
     $this->assertEquals($post_id, $post->ID);
 }
开发者ID:pedrokoblitz,项目名称:centro-dialogo-aberto,代码行数:8,代码来源:test-timber.php

示例4: featured_testimonial

 public function featured_testimonial()
 {
     $cats = wp_get_post_terms($this->ID, 'areas');
     //print_r($cats);
     $tax = array(array('taxonomy' => 'areas', 'field' => 'slug', 'terms' => $cats[0]->slug, 'operator' => 'IN'));
     //print_r($tax);
     $args = array('post_type' => 'testimonials', 'tax_query' => $tax, 'orderby' => 'rand', 'numberposts' => 1);
     return Timber::get_post($args);
 }
开发者ID:jarednova,项目名称:eggs,代码行数:9,代码来源:Gemma_Post.php

示例5: paypal_item_shortcode

 /**
  * paypal_item_shortcode
  *
  */
 public function paypal_item_shortcode($atts)
 {
     $atts = shortcode_atts(array('id' => null), $atts);
     if ($atts['id']) {
         $item = \Timber::get_post($atts['id']);
         if ($item->post_type === 'paypal_item') {
             $account = array('email' => get_field('paypal_email', 'option'), 'currency' => get_field('paypal_currency', 'option'), 'location' => get_field('paypal_location', 'option'));
             return \Timber::compile('paypal-item.twig', array('paypal_item' => $item, 'paypal_account' => $account));
         }
     }
 }
开发者ID:benedict-w,项目名称:pressgang,代码行数:15,代码来源:paypal.php

示例6: TimberPost

<?php

$post = new TimberPost();
$data = Timber::get_context();
$related_posts = yarpp_get_related();
if (!empty($related_posts)) {
    foreach ($related_posts as $related_post) {
        $timber_related_posts[] = Timber::get_post($related_post->ID);
    }
    $data['related_posts'] = $timber_related_posts;
}
$data['post'] = $post;
$data['author_image'] = get_lazyloadxt_html(get_wp_user_avatar($post->author->ID, 150));
Timber::render(array('single.twig'), $data);
开发者ID:saplingdigitalltd,项目名称:thefoodrush,代码行数:14,代码来源:single.php

示例7: get_query_var

$project_slug = get_query_var('project');
if (!empty($project_slug)) {
    $projecte = get_page_by_path($project_slug, OBJECT, 'projecte');
    $projecte = new TimberPost($projecte->ID);
    $content_title = 'Col·laboreu en el projecte ' . $projecte->post_title;
    $projecte->project_requirements = apply_filters('the_content', $projecte->project_requirements);
    $projecte->lectures_recomanades = apply_filters('the_content', $projecte->lectures_recomanades);
    $context_filterer = new SC_ContextFilterer();
    $context = $context_filterer->get_filtered_context(array('title' => $content_title . '| Softcatalà'));
    $context['projecte'] = $projecte;
    $context['steps'] = $projecte->get_field('steps');
    $templates = array('plantilla-steps-single.twig');
    $args = array('meta_query' => array(get_meta_query_value('projectes', $projecte->ID, 'like', '')));
    $context['membres'] = get_users($args);
} else {
    $post = Timber::get_post();
    $profile = $post->get_field('perfil');
    $profile_label = get_field_object('perfil', $post->ID);
    $all_acf_data = get_field_objects($post->ID);
    $content_title = 'Col·laboreu amb nosaltres: ' . $profile_label['choices'][$profile];
    if (false === $profile || empty($profile)) {
        wp_redirect('/col·laboreu/', 302);
    }
    $project_args = array('tax_query' => array(array('taxonomy' => 'ajuda-projecte', 'field' => 'slug', 'terms' => $profile), array('taxonomy' => 'classificacio', 'field' => 'slug', 'terms' => 'arxivat', 'operator' => 'NOT IN')));
    $projects = $sc_types['projectes']->get_sorted_projects($project_args);
    $context = Timber::get_context();
    $context['projectes'] = $projects;
    $context['steps'] = $post->get_field('steps');
}
$post = new TimberPost();
$context['post'] = $post;
开发者ID:softcatala,项目名称:wp-softcatala,代码行数:31,代码来源:plantilla-steps.php

示例8: testGetPostPreview

 function testGetPostPreview()
 {
     $editor_user_id = $this->factory->user->create(array('role' => 'editor'));
     wp_set_current_user($editor_user_id);
     $post_id = $this->factory->post->create(array('post_author' => $editor_user_id));
     _wp_put_post_revision(array('ID' => $post_id, 'post_content' => 'New Stuff Goes here'), true);
     $_GET['preview'] = true;
     $_GET['preview_id'] = $post_id;
     $the_post = Timber::get_post($post_id);
     $this->assertEquals('New Stuff Goes here', $the_post->post_content);
 }
开发者ID:oligoform,项目名称:timber,代码行数:11,代码来源:test-timber.php

示例9: get_header

<?php

get_header();
/*
Template Name: Coaches
*/
$context = array();
// $context = Timber::get_context();
// $post = new TimberPost();
$context['hulk'] = Timber::get_post(94);
$context['posts'] = $post;
Timber::render('hulk-enterprises.twig', $context);
// Timber::render( array( 'page-' . $post->post_name . '.twig', 'coaches.twig' ), $context );
?>


			
			<!-- <div id="content"> -->
			
				<!-- <div id="inner-content" class="row"> -->
			
<!-- 				    <div id="main" class="large-12 medium-12 columns" role="main">
					
				
					    


					    					
    				</div> -->
    				 <!-- end #main -->
    
开发者ID:robertjmcinnis,项目名称:fegym,代码行数:30,代码来源:page-hulk-enterprises.php

示例10: TimberImage

    $billboard_ids[] = $bb->ID;
    $bb->billboard = new TimberImage($bb->billboard);
    if (isset($bb->hero_tease)) {
        $bb->hero_tease = new TimberImage($bb->hero_tease);
    }
    $billboards[] = $bb;
}
// $data['billboards'] = array_slice($billboards, 0, 5);
// $data['plist'] = array_slice($billboards, 5);
$data['billboards'] = $billboards;
$data['clients'] = Timber::get_posts(array('post_type' => 'portfolio', 'numberposts' => -1, 'post__not_in' => $billboard_ids));
$portfolio_client_names = array();
foreach ($data['clients'] as $client) {
    $portfolio_client_names[] = $client->client_name;
}
$client_list = Timber::get_post('client-list');
$client_list = explode("\n", $client_list->post_content);
$client_list = array_unique($client_list);
foreach ($client_list as &$client) {
    $client = trim($client);
}
$data['clients'] = array_merge($data['clients'], $client_list);
$clients = array();
$used_client_names = array();
foreach ($data['clients'] as $client) {
    if (is_string($client)) {
        $client_name = $client;
        $new_client = new stdClass();
        $new_client->client_name = $client_name;
        if (!in_array($client_name, $used_client_names)) {
            $used_client_names[] = $client_name;
开发者ID:ramsaylanier,项目名称:blades,代码行数:31,代码来源:archive-portfolio.php

示例11: TimberPost

$context = Timber::get_context();
$post = new TimberPost();
$context['post'] = $post;
global $paged;
if (!isset($paged) || !$paged) {
    $paged = 1;
}
$custom_args = array('post_status' => 'publish', 'paged' => $paged, 'meta_query' => array(array('key' => '_show_front_page', 'value' => 'yes', 'compare' => '=')));
$my_args = new WP_Query($custom_args);
// echo "<pre>";
// print_r($my_args);
// echo "</pre>";
//$my_query= new WP_Query($custom_args);
$context['homepageposts'] = Timber::get_posts($custom_args);
$context['clients'] = Timber::get_posts('post_type=clients');
$get_tour_page_id = get_post_meta($post->ID, '_my_meta_value_key', true);
if (!empty($get_tour_page_id) && is_numeric($get_tour_page_id)) {
    $context['tour_data'] = Timber::get_post($get_tour_page_id);
}
$context['pagination'] = Timber::get_pagination();
$context['gallery'] = Timber::get_posts('post_type=gallery');
$context['gallery_archieve_link'] = site_url() . '/gallery';
$templates = array('page-' . $post->post_name . '.twig', 'page.twig');
$context['testimonials'] = Timber::get_posts('post_type=testimonial&order=desc&order_by=date');
//Timber::render( array( 'page-' . $post->post_name . '.twig', 'page.twig' ), $context );
/* Snippets */
if (is_home() || is_front_page()) {
    $templates = array('home.twig');
}
Timber::render($templates, $context);
/* End of snippets */
开发者ID:sumeetgohel1990,项目名称:triangle,代码行数:31,代码来源:page.php

示例12: get_header

<?php

get_header();
?>



<?php 
$context = array();
$context['home'] = Timber::get_post(46);
$context['posts'] = Timber::get_posts();
$context['hero_logo'] = get_stylesheet_directory_uri() . '/library/images/fe-fitness-logo-outline.png';
$context['hero_video_mp4'] = get_stylesheet_directory_uri() . '/library/images/fefitness.mp4';
$context['hero_video_webm'] = get_stylesheet_directory_uri() . '/library/images/fefitness.webm';
$context['hero_video_image'] = get_stylesheet_directory_uri() . '/library/images/home/img-hero-barbell.jpg';
Timber::render('index.twig', $context);
?>


<?php 
get_footer();
开发者ID:robertjmcinnis,项目名称:fegym,代码行数:21,代码来源:index.php

示例13: testPagedContent

 function testPagedContent()
 {
     $quote = $page1 = 'Named must your fear be before banish it you can.';
     $quote .= '<!--nextpage-->';
     $quote .= $page2 = "No, try not. Do or do not. There is no try.";
     $post_id = $this->factory->post->create(array('post_content' => $quote));
     $this->go_to(get_permalink($post_id));
     // @todo The below should work magically when the iterators are merged
     setup_postdata(get_post($post_id));
     $post = Timber::get_post();
     $this->assertEquals($page1, trim(strip_tags($post->get_paged_content())));
     $pagination = $post->pagination();
     $this->go_to($pagination['pages'][1]['link']);
     setup_postdata(get_post($post_id));
     $post = Timber::get_post();
     $this->assertEquals($page2, trim(strip_tags($post->get_paged_content())));
 }
开发者ID:rjagadishsingh,项目名称:timber,代码行数:17,代码来源:test-timber-post.php

示例14: array

<?php

$context = Timber::get_context();
$context['page'] = Timber::get_post();
$args = array('post_type' => 'student', 'post_status' => 'publish', 'posts_per_page' => '-1');
$context['students'] = Timber::get_posts($args);
Timber::render('front-page.twig', $context);
开发者ID:sephallen,项目名称:digital-underground,代码行数:7,代码来源:front-page.php

示例15: retrieve_page_data

function retrieve_page_data($page_slug = '')
{
    //Actions to be taken depending on the post type
    switch ($page_slug) {
        case 'noticies':
            $args = array('name' => 'noticies', 'post_type' => 'page');
            $post = Timber::get_post($args);
            break;
        default:
            $args = array('name' => $page_slug . '-page', 'post_type' => 'page');
            $post = Timber::get_post($args);
            break;
    }
    return $post;
}
开发者ID:softcatala,项目名称:wp-softcatala,代码行数:15,代码来源:post_types_functions.php


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