本文整理汇总了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;
}
示例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());
}
示例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);
}
示例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);
}
示例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));
}
}
}
示例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);
示例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;
示例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);
}
示例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 -->
示例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;
示例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 */
示例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();
示例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())));
}
示例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);
示例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;
}