低于这个PHP将打印这样http://example.com/wp-content/uploads/2013/01/imagename.jpg的锚文本“下载”使目标_blank随着这Attacment PHP
<?php
if ($attachments = get_children(array(
'post_type' => 'attachment',
'post_mime_type'=>'image',
'numberposts' => 1,
'post_status' => null,
'post_parent' => $post->ID
)));
foreach ($attachments as $attachment) {
echo wp_get_attachment_link($attachment->ID, '' , false, true, 'Download');
}
?>
1.当用户点击这个链接,如何_blank或在新标签中打开目标。
2.is可能这个短代码结合Javascript来制作强制下载链接?看起来像波纹管。
if ($attachments = get_posts(array(
'post_type' => 'attachment',
'post_mime_type'=>'image',
'numberposts' => -1,
'post_status' => 'any',
'post_parent' => $post->ID,
)));
foreach ($attachments as $attachment) {
echo '<a href="javascript:void(0);"
onclick="document.execCommand(\'SaveAs\', true, \'' . get_permalink($attachment->ID) . '\');">
Download This Wallpaper</a>';
}
解析错误: '' 语法错误,意外 – 2013-03-16 04:07:10
感谢好友.. :) – 2013-03-16 04:15:08
为什么不尝试为你的数组包含一个目标? 阵列( 'post_type'=> '附着', 'post_mime_type'=> '图像', 'numberposts'=> -1, 'post_status'=> '任意', 'post_parent'=> $交 - > ID, 'target'=>'_blank' ) 看看它是否以这种方式工作。 – OmniPotens 2013-03-16 04:22:16