使用WordPress插件自定义帖子类型
Using WordPress plugins for custom post types?
我想为我的图片库添加一个简单的灯箱插件。图像是在一个名为库模板的模板中提取的,如
<?php
$args=array('post_type' => 'gallery');
$query= new WP_Query($args);
while ($query-> have_posts() ) : $query->the_post()?>
<div class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
<h1 class="product_txt"><?php the_title();?></h1>
<a href=''><?php the_post_thumbnail( 'full', array( 'class' => 'product_img') );?></a>
</div>
<?php
endwhile;
?>
我见过很多插件,但他们要求将图像添加到页面中,而不是从模板中获取图像,所以我如何才能让它像这样工作呢?
您可以在没有插件的情况下完成此操作。使用任何您想要的灯箱。我的例子是Prettypoto。
<script src="js/jquery.js" type="text/javascript" charset="utf-8"></script>
<link rel="stylesheet" href="css/prettyPhoto.css" type="text/css" media="screen" charset="utf-8" />
<script src="js/jquery.prettyPhoto.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
$("a[rel^='prettyPhoto']").prettyPhoto();
});
</script>
<?php
$args=array('post_type' => 'gallery');
$query= new WP_Query($args);
while ($query-> have_posts() ) : $query->the_post()?>
<div class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
<?php // Get image url
$attachment = wp_get_attachment_image_src( get_post_thumbnail_id($query->ID), 'full' );
$url = $attachment['0']; ?>
<h1 class="product_txt"><?php the_title();?></h1>
<a rel='prettyPhoto' href='<?php echo $url; ?>'><?php the_post_thumbnail( 'full', array( 'class' => 'product_img') );?></a>
</div>
<?php
endwhile;
?>
相关文章:
- dataTables-如何自定义分页类型以显示最后一个页码后面的省略号,
- WooCommerce的“添加到购物车”按钮旁边的自定义按钮基于产品类型
- 在plone 5中将自定义的灵活性内容类型插入到tinymce编辑器中
- 是否排除节点中错误堆栈的第一行?/节点中的自定义错误类型
- 如何使用URL筛选wordpress自定义帖子类型
- Alfresco JavaScript,当文件上传到网站时,设置自定义类型属性
- 角度形状按钮自定义类型
- WordPress TinyMCE自定义按钮与输入类型编号
- 自定义AJAX数据类型
- 我可以在ebay中使用谷歌网页字体api或任何类型的自定义字体吗
- 如何在自定义帖子类型中添加自定义字段
- 使用 jQuery.load() 查询自定义帖子类型
- 用自定义类型包装 document.createElement()
- WordPress FAQ 手风琴自定义帖子类型 - 匿名函数问题.
- jQuery 图层选择器类型插件或可自定义的列表视图插件
- “未捕获的类型错误:无法读取未定义的属性'嵌入'”在 pdfMake pdf 引擎中使用自定义图像时
- 在 Javascript 中从自定义类型写入数组
- 在 Ajax 调用中设置自定义内容类型响应标头
- 自定义对象/类型 Javascript
- 自定义模块:未捕获类型错误:未定义不是一个函数