Note that there are some explanatory texts on larger screens.

plurals
  1. POwp_get_attachment_url not working
    primarykey
    data
    text
    <p>I have a template file which shows the posts of a category called downloads. for each posts i have attached a pdf file. I have given a link to download the pdf file on the page. But when i click the download link it goes to the post page and from there i have to click to download the file. Is there any way to directly download without going to the post. ? I have tried using wp_get_attachment_url as the hyper-reference.but it is not working.The code that i have used is below: </p> <pre><code>&lt;?php /* Template Name: Downloads Template */ ?&gt; &lt;?php get_header(); ?&gt; &lt;?php $recent = new WP_Query("cat=7&amp;orderby=title&amp;order=ASC"); while($recent-&gt;have_posts()):$recent-&gt;the_post(); $desc_values = get_post_custom_values("description"); ?&gt; &lt;div id="download_featured_image" class="&lt;?php the_ID(); ?&gt; download_image_title_desc"&gt; &lt;a href="&lt;?php the_permalink() ?&gt;" rel="title"&gt; &lt;?php if ( has_post_thumbnail() ) { the_post_thumbnail(); } ?&gt;&lt;/a&gt; &lt;a href = "" &gt; &lt;?php if ( is_user_logged_in() ) { echo "Download"; }?&gt;&lt;/a&gt; &lt;a href=" http://localhost/wordpress/login.php"&gt; &lt;?php if( !(is_user_logged_in()) ) { echo "Please signup/login to download this file"; } ?&gt; &lt;/a&gt; &lt;div id="Download_post_description"&gt; &lt;?php if( is_array( $desc_values ) ) { foreach($desc_values as $key =&gt; $value ); echo "$value&lt;/n&gt;"; } ?&gt; &lt;/div&gt; &lt;/div&gt; &lt;?php endwhile ?&gt; &lt;?php get_footer(); ?&gt; </code></pre> <p>I want to give the link to the uploaded pdf in the href which i have left blank. Can someone help me?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload