php WordPress的自定义库短代码
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php WordPress的自定义库短代码相关的知识,希望对你有一定的参考价值。
function parse_gallery_shortcode($atts) {
global $post;
$output = apply_filters('post_gallery','', $atts);
extract(shortcode_atts(array(
'orderby' => 'menu_order ASC, ID ASC',
'id' => $post->ID,
'itemtag' => 'dl',
'icontag' => 'dt',
'captiontag' => 'dd',
'columns' => 10,
'size' => 'property-thumb',
'link' => 'file',
'ids' => array()
), $atts));
$args = array(
'post_type' => 'attachment',
'posts_per_page' => 10,
'orderby' => $orderby
);
$images = get_posts($args);
echo '<div id="gallery-1" class="custom-gallery">';
foreach ( $images as $image ) {
$caption = $image->post_excerpt;
$description = $image->post_content;
$title = $image->post_title;
$pname = $image->post_name;
$large_img = post_permalink() . $pname . '/';
if($description == '') $description = $title;
$image_alt = get_post_meta($image->ID,'_wp_attachment_image_alt', true);
$img = wp_get_attachment_image_src($image->ID, $size);
// render gallery here
echo '<dl class="gallery-item">';
echo '<dt class="gallery-icon">';
echo '<a title="' . $title . '" href="' . $large_img . '"><img src="' . $img[0] . '" width="' . $img[1] . '" height="' . $img[2] . '"></a>';
echo '</dt>';
echo '</dl>';
}
echo '</div>';
}
以上是关于php WordPress的自定义库短代码的主要内容,如果未能解决你的问题,请参考以下文章
php 标题库短代码和vc插件
Wordpress - 如何通过其分类过滤添加的自定义帖子?
php WordPress的自定义翻译
PHP Wordpress中的自定义字段
PHP Wordpress的自定义登录页面更改
PHP wordpress中的自定义菜单