我有一个模板文件,其中显示了一个名为下载的类别的帖子。对于每个帖子,我都附上了一个pdf文件。我在页面上提供了下载pdf文件的链接。但当我点击下载链接时,它会进入帖子页面,我必须点击下载文件。有没有办法不去发帖就直接下载?我尝试使用wp\\u get\\u attachment\\u url作为超引用。但它不起作用。我使用的代码如下:
<?php /*
Template Name: Downloads Template
*/
?>
<?php get_header(); ?>
<?php
$recent = new WP_Query("cat=7&orderby=title&order=ASC");
while($recent->have_posts()):$recent->the_post();
$desc_values = get_post_custom_values("description");
?>
<div id="download_featured_image" class="<?php the_ID(); ?> download_image_title_desc">
<a href="<?php the_permalink() ?>" rel="title">
<?php
if ( has_post_thumbnail() ) {
the_post_thumbnail();
}
?></a>
<a href = "" > <?php if ( is_user_logged_in() ) {
echo "Download";
}?></a>
<a href="http://localhost/wordpress/login.php "> <?php if( !(is_user_logged_in()) )
{
echo "Please signup/login to download this file";
}
?>
</a>
<div id="Download_post_description">
<?php
if( is_array( $desc_values ) )
{
foreach($desc_values as $key => $value );
echo "$value</n>";
}
?>
</div>
</div>
<?php endwhile ?>
<?php get_footer(); ?>
我想在href中提供上传pdf的链接,我将其留空。有人能帮我吗?