dongshi9526 2017-02-03 10:40
浏览 6

too long

I have a custom post type called 'suppliers' which is used to display a series of supplier's logos in the footer.

<?php $suppliers_loop = new WP_Query( array( 'post_type' => 'suppliers', 'posts_per_page' => 7 ) ); ?>
<?php if ($suppliers_loop->have_posts()):?>
<?php while ( $suppliers_loop->have_posts() ) : $suppliers_loop->the_post(); ?>
<?php $image = get_field('image');?>
    <div class="col-1-7 mobile-col-1-4">
        <a href="<?php echo(get_field('suppliers_url'))?>" target="_blank">
            <img src="<?php echo $image['url'];?>" title="<?php echo $image['title'];?>" alt="<?php echo $image['alt'];?>"/>
        </a>
    </div>
<?php endwhile; ?>
<?php endif; ?>

This works well on every page of the site including other custom post type archives and categories apart from the standard WordPress category page? Where the loop returns:

<div class="col-1-7 mobile-col-1-4">
    <a href="" target="_blank">
        <img src="" title="" alt=""/>
    </a>
</div>

If I replace echo $image['title'] with the_title() it returns:

<div class="col-1-7 mobile-col-1-4">
    <a href="" target="_blank">
        <img src="" title="Digital White Ink" alt=""/>
    </a>
</div>
<div class="col-1-7 mobile-col-1-4">
    <a href="" target="_blank">
        <img src="" title="Environment" alt=""/>
    </a>
</div>
etc..

These returned titles are pages and other post types (some of which are in the bin)? Can anyone shed any light on what on earth is going wrong and how to rectify it?

  • 写回答

1条回答 默认 最新

  • dongzhou4727 2017-02-03 10:49
    关注

    It is better not to change the php file in the wordpress. The code will be back to default if the theme updated.

    My suggestion is change the CSS using "custom css plugin". Sorry for my bad english and thank you.

    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分