【发布时间】:2017-04-11 16:38:14
【问题描述】:
在这里编写 PHP 的新手。几个小时的搜索,不知道我是否在寻找正确的地方。
我有一个自定义分类(目录),其中包含列表的自定义帖子类别。
我正在使用高级自定义字段将图像添加到每个自定义类别(目录图像)。
我目前正在使用下面的代码在自定义目录页面模板中完美地显示自定义类别。
$cat = get_query_var('cat'); $args = array(
'orderby' => 'id',
'child_of' => $cat,
'hide_empty' => 0,
'taxonomy' => directory_categories
);
$categories = get_categories($args);
foreach($categories as $category) {
echo '<a href="' . get_category_link( $category->term_id ) . '" class="cat-icon-view">' . "\n";
echo '<img src=" " width="90%" height="164"></img>' . "\n";
echo ' <h5>' . $category->name . '</h5>' . "\n";
echo '</a>' . "\n";
}$
它有放置图像的空间,但是我对编写 php 标记以包含从自定义类别下的自定义图像字段输出的图像没有信心。
<?php the_field('directory-image', false); ?>
我已经阅读了很多关于在 PHP 中编写 PHP 的页面,但我无法让它工作,我确信有更好的方法:帮助!
Write PHP code in PHP How to write php within html within php? Display Categories with Image in Multiple Pages of Homepage - Magento
【问题讨论】: