1
我一直在這個問題上討論了幾天,所以希望在這裏找到解決方案。Wordpress自定義字段組不顯示所有數據
我試圖顯示來自自定義字段組的數據。下面是我想要達到
基本上是一個樣本佈局,我想顯示20 ++這些列。不過,我只能從這個自定義字段組中獲得大約11個。
這裏是我的頁面的模板代碼:
<?php
/* Template Name: Branches Page */
get_header();
global $currentCity;
$registration_link = get_post_meta(96, 'registration_link', true);
$registration_text = get_post_meta(96, 'registration_text', true);
$thumbnail_url = wp_get_attachment_url(get_post_thumbnail_id($post->ID));
?>
<!-- FEATURE IMAGE
================================================== -->
<?php if(has_post_thumbnail()) { // check for feature image ?>
<section class="feature-image" style="background: url('<?php echo $thumbnail_url; ?>') no-repeat; background-size: cover;" data-type="background" data-speed="2">
<h1 class="page-title"><?php the_title(); ?></h1>
</section>
<?php } else { // fallback image ?>
<section class="feature-image feature-image-default" data-type="background" data-speed="2">
<h1 class="page-title"><?php the_title(); ?></h1>
</section>
<?php } ?>
<!-- MAIN CONTENT
================================================== -->
<div class="container">
<div class="row" id="primary">
<div id="content" class="col-sm-12>
<section class="main-content">
<?php while (have_posts()) : the_post(); ?>
<?php the_content(); ?>
<?php endwhile; // end of the loop ?>
<?php $loop = new WP_Query(array('post_type' => 'branches_locations', 'orderby'=>'post_id', 'order'=>'ASC')); ?>
<div class="resource-row clearfix">
<?php while($loop->have_posts()) : $loop->the_post(); ?>
<?php
$resource_url = get_field('resource_url');
$address = get_field('address');
$city = get_field('city');
$branch_image = get_field('branch_image');
$senior_high_ready = get_field('senior_high_ready');
?>
<div class="resource">
<?php
if($city <> $currentCity)
{
?>
<h2>
<?php echo $city; ?>
</h2>
<?php
}
else
{
?>
<h2 class="hidden-dummy-header">
Blank
<h2>
<?php
}
?>
<h3><?php the_title(); ?></h3>
<p><?php echo $address; ?></p>
<?php
if($senior_high_ready == True)
{
?>
<h5 class="senior_high_ready">
SENIOR HIGH READY
</h5>
<?php
}
else
{
?>
<h5 class="hidden-dummy-header">
Blank
</h5>
<?php
}
?>
<img src="<?php echo $branch_image[url]; ?>" alt="<?php echo $branch_image[alt]; ?>">
<div class="register-link">
<a href="<?php echo $registration_link; ?>" class="btn btn-primary"><?php echo $registration_text; ?>
</a>
</div>
<?php $currentCity = $city; ?>
</div><!-- resource -->
<?php endwhile; ?>
</div><!-- resource-row -->
</section><!-- main-content -->
</div><!-- content -->
</div><!-- row -->
</div><!-- container -->
<?php get_footer(); ?>
是什麼原因造成它不顯示在我的自定義字段組整個列表?
非常感謝。它現在工作! – vishnu
感謝您的更新。是的,下次將使用自定義帖子類型。 – vishnu