0
私たちにはACF Pro for WPがあり、選択された場所を示すACFが作成されています。アドバンストカスタムフィールドが表示されない
私たちは、この取得されて出力しようとして:
お知らせ: /ホーム/ cwplantactiveint/public_htmlの/ WP-コンテンツ/テーマ/ cwplant /ループ・ジョブで非オブジェクトのプロパティを取得しようとします。ライン66本
<?php $location = get_field('job_location'); echo $location->post_title; ?>
は今奇妙な、それは別のカスタムフィールドを出力する
上のPHP createdto出力された日付:
<?php if(get_field('closing_date')) { ?>
<?php the_field('closing_date'); ?>
<?php } else { ?>
Ongoing
<?php } ?>
全体のコードブロックは次のようになります。
<?php while (have_posts()) : the_post(); ?>
<?php /* Check closing date is not past. */
$today = strtotime("now");
$closedate = strtotime(get_field('closing_date'));
if ($today < $closedate || !get_field('closing_date')) {
?>
<div class="singlepost infobox info-job content cfix">
<h2><a href="<?php the_permalink(); ?>" title="<?php printf(esc_attr__('Permalink to %s', 'twentyten'), the_title_attribute('echo=0')); ?>"><?php the_title(); ?></a></h2>
<p><span class="red first">Location:</span> <?php $location = get_field('job_location'); echo $location->post_title; ?>
<span class="red">Closing Date:</span>
<?php if(get_field('closing_date')) { ?>
<?php the_field('closing_date'); ?>
<?php } else { ?>
Ongoing
<?php } ?>
</p>
<?php if (is_archive() || is_search() || is_home()) : // Only display excerpts for archives and search. ?>
<?php the_excerpt(); ?>
<a class="button" href="<?php the_permalink(); ?>">View Details</a>
<?php else : ?>
<?php the_content(__('Continue reading →', 'twentyten')); ?>
<?php endif; ?>
</div>
<?php $jobstrue = 'true'; ?>
<?php } else { ?>
<?php $jobsfalse = 'true'; ?>
<?php } ?>
<?php endwhile; // End the loop. Whew. ?>
注: '$ closedate =のstrtotime(get_field( 'closing_date'));' - 'get_field ($ location){do_something} 'のようにポストする必要があります。 –
これは、' true 'または 'false'を返すでしょう。' the_field(' closing_date ') 'アーカイブテンプレートまたは通常のテンプレートですか? – staypuftman
@staypuftmanこれは標準の新しいページテンプレートです。 – PhpDude