0
我正在嘗試創建一個頁面來提取自定義發佈類型(團隊)和相應的高級自定義字段,並將它們顯示在模板團隊頁面上。我在Genesis中通過合併一段爲WordPress開發的代碼(非創世),在tutorial之後合併。PHP /創世紀:創世紀循環中的高級自定義字段
我取得了一些進展,但我被卡在高級自定義字段。例如,<?php the_title(); ?>
實際上調用PAGE標題,而不是自定義帖子的標題。而其他領域(職位,電話等)不起作用 - 他們根本沒有被調用。我確信這是我將代碼與Genesis合併的一個問題。
<?php
/**
* This file adds the city team template to any Genesis 2.0+ Theme.
*
* @author Jim Thornton
* @package InboundFound
* @subpackage Customizations
*/
/*
Template Name: Team
*/
?>
<?php
remove_action('genesis_loop', 'genesis_do_loop');
add_action('genesis_loop', 'your_custom_loop');
function your_custom_loop() {
// Get 'team' posts
$team_posts = get_posts(array(
'post_type' => 'team',
'posts_per_page' => -1, // Unlimited posts
'orderby' => 'title', // Order alphabetically by name
));
if ($team_posts):
?>
<section class="row profiles">
<div class="intro">
<h2>Meet The Team</h2>
<p class="lead"></p>
</div>
<?php
foreach ($team_posts as $post):
setup_postdata($post);
// Resize and CDNize thumbnails using Automattic Photon service
$thumb_src = null;
if (has_post_thumbnail($post->ID)) {
$src = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'team-thumb');
$thumb_src = $src[0];
}
?>
<article class="col-sm-6 profile">
<div class="profile-header">
<?php if ($thumb_src): ?>
<img src="<?php echo $thumb_src; ?>" alt="<?php the_title(); ?>, <?php the_field('team_position'); ?>" class="img-circle">
<?php endif; ?>
</div>
<div class="profile-content">
<h3><?php the_title(); ?></h3>
<p class="lead position"><?php the_field('team_position'); ?></p>
<?php the_content(); ?>
</div>
<div class="profile-footer">
<a href="tel:<?php the_field('team_phone'); ?>"><i class="icon-mobile-phone"></i></a>
<a href="mailto:<?php echo antispambot(get_field('team_email')); ?>"><i class="icon-envelope"></i></a>
<?php if ($twitter = get_field('team_twitter')): ?>
<a href="<?php echo $twitter; ?>"><i class="icon-twitter"></i></a>
<?php endif; ?>
<?php if ($linkedin = get_field('team_linkedin')): ?>
<a href="<?php echo $linkedin; ?>"><i class="icon-linkedin"></i></a>
<?php endif; ?>
</div>
</article><!-- /.profile -->
<?php endforeach; ?>
</section><!-- /.row -->
<?php endif;
}
genesis();