问题描述
我想将图库模板添加到儿童主题,并且发现很难找到好的示例。迄今为止,我发现的最好的示例是Andres Hermosilla,但该示例可以追溯到2012年。
第1步到第3步将使我得到一半的收益,这是在网站标题上方插入的图片库(此阶段我不需要fluxslider或类似工具。)以下是我正在使用的代码在the_title()
之前:
<?PHP
$image_args = array(
'numberposts' => -1,// Using -1 loads all posts
'orderby' => 'menu_order',// This ensures images are in the order set in the page media manager
'order'=> 'ASC','post_mime_type' => 'image',// Make sure it doesn't pull other resources,like videos
'post_parent' => $post->ID,// Important part - ensures the associated images are loaded
'post_status' => null,'post_type' => 'attachment'
);
$images = get_children( $image_args );
if ( $images ) {
foreach ( $images as $image ) { ?>
<img src="<?PHP echo $image->guid; ?>" alt="<?PHP echo $image->post_title; ?>" title="<?PHP echo $image->post_title; ?>" />
<?PHP }
} ?>
我的问题是图像本身仍显示在帖子的内容中-如何同时从页面内容中删除所有图像?
解决方法
为什么不将类添加到画廊模板页面,并且不显示所有图像,除了使用CSS的画廊图像。