如何在index.php的首页中显示ACF值

时间:2014-11-14 12:05:53

标签: wordpress advanced-custom-fields

嗨,大家好,我的名字是Fotis,我是一名初级网络开发者。

我需要您帮助的原因是因为我正在尝试创建此图库http://www.elliotcondon.com/creating-an-image-gallery-with-advanced-custom-fields/,而我正在使用自定义字段和添加转发器。

但是我在浏览器和主页上看不到任何内容。但是当我创建另一个页面模板而没有beign声明为首页或页面的帖子时它工作正常。所以问题是我应该在代码中包含什么来实现这一目标。?

请任何知道帮助我的人

感谢您阅读我的要求!

<?php get_header(); ?>
<div id="content">
<div id="main">
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    <h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
        <?php the_content(); ?>
    <?php endwhile; else: endif; ?>
<?php query_posts('category_name='.get_the_title().'&post_status=publish,future');?>
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    <h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
    <p><?php the_content(); ?>
    <?php endwhile; else: endif; ?>
<!-- Slider -->
    <?php if(get_field('images')): ?>
    <div id="slider">
        <?php while(the_repeater_field('images')): ?>
            <?php $image = wp_get_attachment_image_src(get_sub_field('image'), 'full'); ?>
            <?php $thumb = wp_get_attachment_image_src(get_sub_field('image'), 'thumbnail'); ?>
            <img src="<?php echo $image[0]; ?>" alt="<?php  the_sub_field('title');?>" rel="<?php echo $thumb[0]; ?>" />
        <?php endwhile; ?>
    </div>
    <?php endif; ?>


</div>
</div>

0 个答案:

没有答案
相关问题