Grid Pluging功能强大,但没有太多文档。
我有一个自定义帖子类型,带有一个cpt.php文件,除了我需要遍历插入中的图片库图像并回显其URL之外,其他所有内容均正确显示。尚未完成。
唯一的文档是他们在其网站https://theme-one.com/docs/the-grid/上提供的文档
每个CPT都有一个不同的图库,我需要知道一种循环并回显它们的方法。
我已经尝试过很多次了,这是我最后的代码。
<?php
// Init The Grid Elements instance
$tg_el = The_Grid_Elements();
// Prepare main data for futur conditions
$image = $tg_el->get_attachment_url();
$format = $tg_el->get_item_format();
$media = in_array($formats, array('gallery'));
foreach ($media as $medias) {
echo "<p>Hola</p>";
}
echo $tg_el->get_item_format();
echo $tg_el->get_item_ID('gallery');
?>
循环中的“ hola”正在测试打印了多少次,以查看我是否走对了路
然后,我将所有meta字段打印在帖子类型上,以查看是否可以识别出有助于循环的内容。
<?php
$post_id = get_the_ID();
<?php $meta = get_post_meta($post_id); ?>
<?php $key_1_values = get_post_meta( 76, 'key_1' ); ?>
<?php
$myvals = get_post_meta($post_id);
foreach($myvals as $key=>$val)
{
echo $key . ' : ' . $val[0] . '<br/>';
}
?>
这回荡了
_edit_last : 1
slide_template : default
the_grid_item_custom_link_target : _self
the_grid_item_col : 1
the_grid_item_row : 1
the_grid_item_content_color : dark
the_grid_item_overlay_color : light
the_grid_item_gallery : 594,595,596,597
the_grid_item_video_ratio : 4:3
the_grid_item_youtube_ratio : 4:3
the_grid_item_vimeo_ratio : 4:3
the_grid_item_wistia_ratio : 4:3
_edit_lock : 1545151448:1
the_grid_item_format : gallery
希望我能提供足够的信息
如果您想动手测试一下就可以了。 https://drive.google.com/drive/folders/1QbbyAOBOlHHtoCO2ESJggGu3QIlBk9aq?usp=sharing