<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>download属性 &#8211; ケケンタの独学ITブログ</title>
	<atom:link href="https://kekenta-it-blog.com/tag/download%E5%B1%9E%E6%80%A7/feed/" rel="self" type="application/rss+xml" />
	<link>https://kekenta-it-blog.com</link>
	<description>プログラミングやWeb制作の情報を発信</description>
	<lastBuildDate>Tue, 18 Mar 2025 02:14:05 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0</generator>

<image>
	<url>https://kekenta-it-blog.com/wp-content/uploads/2023/07/cropped-KEKENTA-BLOG-32x32.png</url>
	<title>download属性 &#8211; ケケンタの独学ITブログ</title>
	<link>https://kekenta-it-blog.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>【WordPress】画像・ファイルがダウンロードできるリンクの作成方法【ACF】</title>
		<link>https://kekenta-it-blog.com/wp-download-link/</link>
					<comments>https://kekenta-it-blog.com/wp-download-link/#respond</comments>
		
		<dc:creator><![CDATA[ケケンタ]]></dc:creator>
		<pubDate>Mon, 03 Jun 2024 08:11:56 +0000</pubDate>
				<category><![CDATA[ACF]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[download属性]]></category>
		<guid isPermaLink="false">https://kekenta-it-blog.com/?p=7639</guid>

					<description><![CDATA[<p><img src="https://kekenta-it-blog.com/wp-content/uploads/2024/06/eye-catch__wp-download-link__7639-1024x576.jpg" class="webfeedsFeaturedVisual" /></p>今回はこのようなお悩みをお持ちの方に向けて WordPressでクリックしたら画像やファイルをダウンロードできるリンクを作成する方法 をご紹介していきます。 今回使用する技術・機能の解説 具体的な解説に入る前に、まずは今 [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><img src="https://kekenta-it-blog.com/wp-content/uploads/2024/06/eye-catch__wp-download-link__7639-1024x576.jpg" class="webfeedsFeaturedVisual" /></p><div class="swell-block-balloon"><div class="c-balloon -bln-left" data-col="gray"><div class="c-balloon__icon -circle"><img decoding="async" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-src="https://kekenta-it-blog.com/wp-content/uploads/2023/07/困った顔-150x150.jpg" alt="" class="lazyload c-balloon__iconImg" width="80px" height="80px"><noscript><img decoding="async" src="https://kekenta-it-blog.com/wp-content/uploads/2023/07/困った顔-150x150.jpg" alt="" class="c-balloon__iconImg" width="80px" height="80px"></noscript><span class="c-balloon__iconName">ケケンタ</span></div><div class="c-balloon__body -speaking -border-on"><div class="c-balloon__text">
<p>WordPressでリンクをクリックしたら画像やファイルをダウンロードできるようにしたいんだけど、具体的にはどうすれば良いんだろう……</p>
<span class="c-balloon__shapes"><span class="c-balloon__before"></span><span class="c-balloon__after"></span></span></div></div></div></div>


<p class="wp-block-paragraph">今回はこのようなお悩みをお持ちの方に向けて</p>



<p class="has-text-align-center is-style-big_kakko_box wp-block-paragraph"><strong>WordPressでクリックしたら画像やファイルを<br>ダウンロードできるリンクを作成する方法</strong></p>



<p class="wp-block-paragraph">をご紹介していきます。</p>


<div class="swell-block-balloon"><div class="c-balloon -bln-left" data-col="gray"><div class="c-balloon__icon -circle"><img decoding="async" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-src="https://kekenta-it-blog.com/wp-content/uploads/2023/07/キリッ-150x150.jpg" alt="" class="lazyload c-balloon__iconImg" width="80px" height="80px"><noscript><img decoding="async" src="https://kekenta-it-blog.com/wp-content/uploads/2023/07/キリッ-150x150.jpg" alt="" class="c-balloon__iconImg" width="80px" height="80px"></noscript><span class="c-balloon__iconName">ケケンタ</span></div><div class="c-balloon__body -speaking -border-on"><div class="c-balloon__text">
<p>基本的なやり方はWordPressを使わない場合（HTMLサイト）と同じですが、WordPressでは<strong>ダウンロード用リンクをカスタムフィールドを用いて設置する</strong>のが便利なので、今回はその方向性で解説をしていきます。</p>
<span class="c-balloon__shapes"><span class="c-balloon__before"></span><span class="c-balloon__after"></span></span></div></div></div></div>

<div class="swell-block-postLink">			<a href="https://kekenta-it-blog.com/wp-how-to-load-js/" class="c-blogLink -internal" data-style="text">
				<!-- <i class="c-blogLink__icon icon-link" role="presentation"></i> -->
				<span class="c-blogLink__icon">
					<svg xmlns="http://www.w3.org/2000/svg" class="swl-svg-link __svg" width="1em" height="1em" viewBox="0 0 48 48" role="img" aria-hidden="true" focusable="false"><path d="M21.2 30.2c-.5 0-1-.2-1.4-.6l-.7-.7c-2.3-2.3-3.5-5.3-3.5-8.5s1.2-6.2 3.5-8.5l7.1-7.1c2.3-2.3 5.3-3.5 8.5-3.5s6.2 1.2 8.5 3.5c4.7 4.7 4.7 12.3 0 17l-3.5 3.5c-.8.8-2 .8-2.8 0-.8-.8-.8-2 0-2.8l3.5-3.5c3.1-3.1 3.1-8.2 0-11.3-1.5-1.5-3.5-2.3-5.7-2.3-2.1 0-4.2.8-5.7 2.3l-7.1 7.1c-1.5 1.5-2.3 3.5-2.3 5.7s.8 4.2 2.3 5.7l.7.7c.8.8.8 2 0 2.8-.4.3-.9.5-1.4.5z" /><path d="M13.4 46.6c-3.1 0-6.1-1.2-8.5-3.5-2.3-2.3-3.5-5.3-3.5-8.5s1.2-6.2 3.5-8.5l3.5-3.5c.8-.8 2-.8 2.8 0 .8.8.8 2 0 2.8l-3.5 3.5c-1.5 1.5-2.3 3.5-2.3 5.7 0 2.1.8 4.2 2.3 5.7 3.1 3.1 8.2 3.1 11.3 0l7.1-7.1c1.5-1.5 2.3-3.5 2.3-5.7 0-2.1-.8-4.2-2.3-5.7l-.7-.7c-.8-.8-.8-2 0-2.8.8-.8 2-.8 2.8 0l.7.7c2.3 2.3 3.5 5.3 3.5 8.5s-1.2 6.2-3.5 8.5l-7.1 7.1c-2.3 2.3-5.3 3.5-8.4 3.5z" /></svg>				</span>
				<span class="c-blogLink__text">【WordPress】JavaScriptはどこに書けばいい？「３つの方法」を解説</span>
			</a>
		</div>

<div class="swell-block-postLink">			<a href="https://kekenta-it-blog.com/wp-read-css-per-page/" class="c-blogLink -internal" data-style="text">
				<!-- <i class="c-blogLink__icon icon-link" role="presentation"></i> -->
				<span class="c-blogLink__icon">
					<svg xmlns="http://www.w3.org/2000/svg" class="swl-svg-link __svg" width="1em" height="1em" viewBox="0 0 48 48" role="img" aria-hidden="true" focusable="false"><path d="M21.2 30.2c-.5 0-1-.2-1.4-.6l-.7-.7c-2.3-2.3-3.5-5.3-3.5-8.5s1.2-6.2 3.5-8.5l7.1-7.1c2.3-2.3 5.3-3.5 8.5-3.5s6.2 1.2 8.5 3.5c4.7 4.7 4.7 12.3 0 17l-3.5 3.5c-.8.8-2 .8-2.8 0-.8-.8-.8-2 0-2.8l3.5-3.5c3.1-3.1 3.1-8.2 0-11.3-1.5-1.5-3.5-2.3-5.7-2.3-2.1 0-4.2.8-5.7 2.3l-7.1 7.1c-1.5 1.5-2.3 3.5-2.3 5.7s.8 4.2 2.3 5.7l.7.7c.8.8.8 2 0 2.8-.4.3-.9.5-1.4.5z" /><path d="M13.4 46.6c-3.1 0-6.1-1.2-8.5-3.5-2.3-2.3-3.5-5.3-3.5-8.5s1.2-6.2 3.5-8.5l3.5-3.5c.8-.8 2-.8 2.8 0 .8.8.8 2 0 2.8l-3.5 3.5c-1.5 1.5-2.3 3.5-2.3 5.7 0 2.1.8 4.2 2.3 5.7 3.1 3.1 8.2 3.1 11.3 0l7.1-7.1c1.5-1.5 2.3-3.5 2.3-5.7 0-2.1-.8-4.2-2.3-5.7l-.7-.7c-.8-.8-.8-2 0-2.8.8-.8 2-.8 2.8 0l.7.7c2.3 2.3 3.5 5.3 3.5 8.5s-1.2 6.2-3.5 8.5l-7.1 7.1c-2.3 2.3-5.3 3.5-8.4 3.5z" /></svg>				</span>
				<span class="c-blogLink__text">【WordPress】特定ページにCSSを読み込む「５つ」の方法【早見リスト付】</span>
			</a>
		</div>

<div class="swell-block-postLink">			<a href="https://kekenta-it-blog.com/wp-subloop-wq/" class="c-blogLink -internal" data-style="text">
				<!-- <i class="c-blogLink__icon icon-link" role="presentation"></i> -->
				<span class="c-blogLink__icon">
					<svg xmlns="http://www.w3.org/2000/svg" class="swl-svg-link __svg" width="1em" height="1em" viewBox="0 0 48 48" role="img" aria-hidden="true" focusable="false"><path d="M21.2 30.2c-.5 0-1-.2-1.4-.6l-.7-.7c-2.3-2.3-3.5-5.3-3.5-8.5s1.2-6.2 3.5-8.5l7.1-7.1c2.3-2.3 5.3-3.5 8.5-3.5s6.2 1.2 8.5 3.5c4.7 4.7 4.7 12.3 0 17l-3.5 3.5c-.8.8-2 .8-2.8 0-.8-.8-.8-2 0-2.8l3.5-3.5c3.1-3.1 3.1-8.2 0-11.3-1.5-1.5-3.5-2.3-5.7-2.3-2.1 0-4.2.8-5.7 2.3l-7.1 7.1c-1.5 1.5-2.3 3.5-2.3 5.7s.8 4.2 2.3 5.7l.7.7c.8.8.8 2 0 2.8-.4.3-.9.5-1.4.5z" /><path d="M13.4 46.6c-3.1 0-6.1-1.2-8.5-3.5-2.3-2.3-3.5-5.3-3.5-8.5s1.2-6.2 3.5-8.5l3.5-3.5c.8-.8 2-.8 2.8 0 .8.8.8 2 0 2.8l-3.5 3.5c-1.5 1.5-2.3 3.5-2.3 5.7 0 2.1.8 4.2 2.3 5.7 3.1 3.1 8.2 3.1 11.3 0l7.1-7.1c1.5-1.5 2.3-3.5 2.3-5.7 0-2.1-.8-4.2-2.3-5.7l-.7-.7c-.8-.8-.8-2 0-2.8.8-.8 2-.8 2.8 0l.7.7c2.3 2.3 3.5 5.3 3.5 8.5s-1.2 6.2-3.5 8.5l-7.1 7.1c-2.3 2.3-5.3 3.5-8.4 3.5z" /></svg>				</span>
				<span class="c-blogLink__text">【WordPress】WP_Query（サブループ）の使い方とパラメータ一覧を紹介</span>
			</a>
		</div>

<div class="swell-block-postLink">			<a href="https://kekenta-it-blog.com/change-to-swell/" class="c-blogLink -internal" data-style="text">
				<!-- <i class="c-blogLink__icon icon-link" role="presentation"></i> -->
				<span class="c-blogLink__icon">
					<svg xmlns="http://www.w3.org/2000/svg" class="swl-svg-link __svg" width="1em" height="1em" viewBox="0 0 48 48" role="img" aria-hidden="true" focusable="false"><path d="M21.2 30.2c-.5 0-1-.2-1.4-.6l-.7-.7c-2.3-2.3-3.5-5.3-3.5-8.5s1.2-6.2 3.5-8.5l7.1-7.1c2.3-2.3 5.3-3.5 8.5-3.5s6.2 1.2 8.5 3.5c4.7 4.7 4.7 12.3 0 17l-3.5 3.5c-.8.8-2 .8-2.8 0-.8-.8-.8-2 0-2.8l3.5-3.5c3.1-3.1 3.1-8.2 0-11.3-1.5-1.5-3.5-2.3-5.7-2.3-2.1 0-4.2.8-5.7 2.3l-7.1 7.1c-1.5 1.5-2.3 3.5-2.3 5.7s.8 4.2 2.3 5.7l.7.7c.8.8.8 2 0 2.8-.4.3-.9.5-1.4.5z" /><path d="M13.4 46.6c-3.1 0-6.1-1.2-8.5-3.5-2.3-2.3-3.5-5.3-3.5-8.5s1.2-6.2 3.5-8.5l3.5-3.5c.8-.8 2-.8 2.8 0 .8.8.8 2 0 2.8l-3.5 3.5c-1.5 1.5-2.3 3.5-2.3 5.7 0 2.1.8 4.2 2.3 5.7 3.1 3.1 8.2 3.1 11.3 0l7.1-7.1c1.5-1.5 2.3-3.5 2.3-5.7 0-2.1-.8-4.2-2.3-5.7l-.7-.7c-.8-.8-.8-2 0-2.8.8-.8 2-.8 2.8 0l.7.7c2.3 2.3 3.5 5.3 3.5 8.5s-1.2 6.2-3.5 8.5l-7.1 7.1c-2.3 2.3-5.3 3.5-8.4 3.5z" /></svg>				</span>
				<span class="c-blogLink__text">無料テーマCocoonからSWELLに乗り換えた７つの理由【WordPress】</span>
			</a>
		</div>

<div class="swell-block-postLink">			<div class="p-blogCard -internal" data-type="type2" data-onclick="clickLink">
				<div class="p-blogCard__inner">
					<span class="p-blogCard__caption">あわせて読みたい</span>
					<div class="p-blogCard__thumb c-postThumb"><figure class="c-postThumb__figure"><img decoding="async" src="https://kekenta-it-blog.com/wp-content/uploads/2025/03/eye-catch__school-php-and-wp__14099-300x169.jpg" alt="" class="c-postThumb__img u-obf-cover" width="320" height="180"></figure></div>					<div class="p-blogCard__body">
						<a class="p-blogCard__title" href="https://kekenta-it-blog.com/school-php-and-wp/">PHPやWordPressを学ぶのにおすすめのプログラミングスクール【７選】</a>
						<span class="p-blogCard__excerpt">僕はこれまで独学でPHPを学習してきました。結論から言えば、それでもPHPを習得することはできました。 しかし、それに費やした累計学習期間は1年ほど。モチベーション&#8230;</span>					</div>
				</div>
			</div>
		</div>


<h2 class="wp-block-heading">今回使用する技術・機能の解説</h2>



<p class="wp-block-paragraph">具体的な解説に入る前に、まずは<strong>今回使用する技術・WordPressの機能</strong>についてご紹介をします。</p>



<div class="swell-block-capbox cap_box"><div class="cap_box_ttl"><span><strong>今回使用する技術・WordPressの機能</strong></span></div><div class="cap_box_content">
<ul class="wp-block-list is-style-num_circle -list-under-dashed">
<li>aタグのdownload属性</li>



<li>WordPressプラグイン「ACF」のファイルフィールド</li>
</ul>
</div></div>


<div class="swell-block-balloon"><div class="c-balloon -bln-left" data-col="gray"><div class="c-balloon__icon -circle"><img decoding="async" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-src="https://kekenta-it-blog.com/wp-content/uploads/2023/07/キリッ-150x150.jpg" alt="" class="lazyload c-balloon__iconImg" width="80px" height="80px"><noscript><img decoding="async" src="https://kekenta-it-blog.com/wp-content/uploads/2023/07/キリッ-150x150.jpg" alt="" class="c-balloon__iconImg" width="80px" height="80px"></noscript><span class="c-balloon__iconName">ケケンタ</span></div><div class="c-balloon__body -speaking -border-on"><div class="c-balloon__text">
<p>まずはこれら２つの技術・機能について具体的にご紹介していきます。</p>
<span class="c-balloon__shapes"><span class="c-balloon__before"></span><span class="c-balloon__after"></span></span></div></div></div></div>


<h3 class="wp-block-heading">aタグのdownload属性</h3>



<p class="wp-block-paragraph">みなさんご存じのaタグには、<strong>download属性</strong>というものが使用できます。</p>



<p class="wp-block-paragraph">これをaタグに指定するだけで、実は簡単に「画像やファイルをダウンロードできるリンク」ができあがります。</p>



<p class="is-style-balloon_box2 wp-block-paragraph">aタグにdownload属性を指定する（実例）</p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-html" data-lang="HTML"><code>&lt;a href=&quot;ダウンロードさせたいファイルの絶対パスまたは相対パス&quot; download&gt;リンク名&lt;/a&gt;</code></pre></div>



<p class="is-style-big_icon_check wp-block-paragraph">この書き方の場合、ダウンロードしたファイル名はパスで使用しているファイル名そのままになる</p>



<p class="is-style-balloon_box2 wp-block-paragraph">ダウンロードするファイルの名前を指定したい場合</p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-html" data-lang="HTML"><code>&lt;a href=&quot;ダウンロードさせたいファイルの絶対パスまたは相対パス&quot; download=&quot;任意のファイル名&quot;&gt;リンク名&lt;/a&gt;</code></pre></div>


<div class="swell-block-balloon"><div class="c-balloon -bln-left" data-col="gray"><div class="c-balloon__icon -circle"><img decoding="async" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-src="https://kekenta-it-blog.com/wp-content/uploads/2023/07/キリッ-150x150.jpg" alt="" class="lazyload c-balloon__iconImg" width="80px" height="80px"><noscript><img decoding="async" src="https://kekenta-it-blog.com/wp-content/uploads/2023/07/キリッ-150x150.jpg" alt="" class="c-balloon__iconImg" width="80px" height="80px"></noscript><span class="c-balloon__iconName">ケケンタ</span></div><div class="c-balloon__body -speaking -border-on"><div class="c-balloon__text">
<p>aタグにこのように記述するだけで簡単にダウンロード用リンクが作成できます。</p>
<span class="c-balloon__shapes"><span class="c-balloon__before"></span><span class="c-balloon__after"></span></span></div></div></div></div>


<p class="wp-block-paragraph">ただし、aタグのdownload属性には<strong><span class="swl-marker mark_orange">使用上の注意点</span></strong>があります。</p>



<p class="wp-block-paragraph">以下の点に気を付けて使用するようにしましょう。</p>



<div class="swell-block-capbox cap_box" data-colset="col3"><div class="cap_box_ttl"><span>download属性の注意点</span></div><div class="cap_box_content">
<ul class="wp-block-list is-style-bad_list -list-under-dashed">
<li>外部のサイトのファイルをダウンロードさせることはできない（自サイト内＝同じドメインのファイルのみダウンロード可能）</li>



<li>IEは非対応（別タブで開く動作になる）</li>
</ul>
</div></div>



<h3 class="wp-block-heading">ACFのファイルフィールド</h3>



<p class="wp-block-paragraph">続いて使用するのがWordPressプラグインの「ACF」です。</p>



<div class="swell-block-capbox cap_box"><div class="cap_box_ttl"><span>ACF（Advanced Custom Fields）とは？</span></div><div class="cap_box_content">
<p class="wp-block-paragraph">ACFは誰でも簡単に<strong>カスタムフィールドの追加・編集を可能にする</strong>、WordPressプラグインのひとつです。</p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">カスタムフィールドを自作しようとすると、functions.phpに何行ものコードを記述する必要があり手間がかかりますが、ACFを利用することで簡単に様々な種類のカスタムフィールドを導入できます。</p>
</div></div>



<p class="wp-block-paragraph">今回はこのACFの「ファイルフィールド」を使用してダウンロード用リンクを設置します。</p>



<p class="is-style-big_icon_point wp-block-paragraph">ファイルフィールドを使用するとあらゆるタイプのファイルをカスタムフィールドに設定できる。</p>



<h2 class="wp-block-heading">WordPressにアップロードできるファイルタイプを増やす方法</h2>



<p class="wp-block-paragraph">ここまでに「ダウンロード用リンクをWordPressで設定するために使用する技術・機能」をご紹介してきました。</p>



<p class="wp-block-paragraph">しかし、WordPressの場合はそれだけでは以下の理由により、対応が不十分になってしまう場合があるため、本章ではそれを補うためのプラグインをもうひとつご紹介します。</p>



<p class="is-style-icon_bad wp-block-paragraph">WordPressの初期状態ではai形式やsvg形式など<strong>特殊なファイルをアップロードできない</strong></p>



<p class="wp-block-paragraph">様々なタイプのファイルをアップロードできるようにするためのプラグインとして<strong>「WP Add Mime Types」</strong>を使用します。</p>


<div class="swell-block-balloon"><div class="c-balloon -bln-left" data-col="gray"><div class="c-balloon__icon -circle"><img decoding="async" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-src="https://kekenta-it-blog.com/wp-content/uploads/2023/07/キリッ-150x150.jpg" alt="" class="lazyload c-balloon__iconImg" width="80px" height="80px"><noscript><img decoding="async" src="https://kekenta-it-blog.com/wp-content/uploads/2023/07/キリッ-150x150.jpg" alt="" class="c-balloon__iconImg" width="80px" height="80px"></noscript><span class="c-balloon__iconName">ケケンタ</span></div><div class="c-balloon__body -speaking -border-on"><div class="c-balloon__text">
<p>以下は「<strong>WP Add Mime Types</strong>」の設定画面です。</p>
<span class="c-balloon__shapes"><span class="c-balloon__before"></span><span class="c-balloon__after"></span></span></div></div></div></div>


<figure class="wp-block-image size-full is-style-photo_frame size_xs"><img decoding="async" width="773" height="600" src="https://kekenta-it-blog.com/wp-content/uploads/2024/06/image-5.png" alt="" class="wp-image-7653" srcset="https://kekenta-it-blog.com/wp-content/uploads/2024/06/image-5.png 773w, https://kekenta-it-blog.com/wp-content/uploads/2024/06/image-5-300x233.png 300w, https://kekenta-it-blog.com/wp-content/uploads/2024/06/image-5-768x596.png 768w" sizes="(max-width: 773px) 100vw, 773px" /></figure>



<p class="is-style-big_icon_point wp-block-paragraph">「<strong>WP Add Mime Types</strong>」をインストールして有効化するだけで、様々なタイプのファイルのアップロードができるようになります。</p>



<h3 class="wp-block-heading">「ai」や「eps」形式もアップロード可能にしたいとき</h3>



<p class="wp-block-paragraph">ただ、実を言うと「WP Add Mime Types」を有効化しただけでは「ai」や「eps」形式のファイルをアップロードすることはできません。</p>


<div class="swell-block-balloon"><div class="c-balloon -bln-left" data-col="gray"><div class="c-balloon__icon -circle"><img decoding="async" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-src="https://kekenta-it-blog.com/wp-content/uploads/2023/07/キリッ-150x150.jpg" alt="" class="lazyload c-balloon__iconImg" width="80px" height="80px"><noscript><img decoding="async" src="https://kekenta-it-blog.com/wp-content/uploads/2023/07/キリッ-150x150.jpg" alt="" class="c-balloon__iconImg" width="80px" height="80px"></noscript><span class="c-balloon__iconName">ケケンタ</span></div><div class="c-balloon__body -speaking -border-on"><div class="c-balloon__text">
<p>もしも「ai」や「eps」形式もアップロード可能にしたいときは、<br><strong>「WP Add Mime Types」の「追加の項目」に以下の2行を追加し「設定を保存」をクリック</strong>します。</p>
<span class="c-balloon__shapes"><span class="c-balloon__before"></span><span class="c-balloon__after"></span></span></div></div></div></div>


<p class="is-style-balloon_box2 wp-block-paragraph">「追加の項目」に以下の2行を追加</p>



<p class="is-style-bg_stripe wp-block-paragraph">ai = application/postscript<br>eps = appilcation/postscript</p>



<figure class="wp-block-image size-full size_xs"><img decoding="async" width="770" height="519" src="https://kekenta-it-blog.com/wp-content/uploads/2024/06/image-7.png" alt="" class="wp-image-7658" srcset="https://kekenta-it-blog.com/wp-content/uploads/2024/06/image-7.png 770w, https://kekenta-it-blog.com/wp-content/uploads/2024/06/image-7-300x202.png 300w, https://kekenta-it-blog.com/wp-content/uploads/2024/06/image-7-768x518.png 768w" sizes="(max-width: 770px) 100vw, 770px" /></figure>


<div class="swell-block-balloon"><div class="c-balloon -bln-left" data-col="gray"><div class="c-balloon__icon -circle"><img decoding="async" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-src="https://kekenta-it-blog.com/wp-content/uploads/2023/07/キリッ-150x150.jpg" alt="" class="lazyload c-balloon__iconImg" width="80px" height="80px"><noscript><img decoding="async" src="https://kekenta-it-blog.com/wp-content/uploads/2023/07/キリッ-150x150.jpg" alt="" class="c-balloon__iconImg" width="80px" height="80px"></noscript><span class="c-balloon__iconName">ケケンタ</span></div><div class="c-balloon__body -speaking -border-on"><div class="c-balloon__text">
<p>たったこれだけで、「ai」や「eps」形式のファイルもアップロードできるようになります。</p>
<span class="c-balloon__shapes"><span class="c-balloon__before"></span><span class="c-balloon__after"></span></span></div></div></div></div>


<h2 class="wp-block-heading">ワンクリックで画像がダウンロードできるリンクの作成手順</h2>



<p class="wp-block-paragraph">前置きが長くなりましたが、ここからは具体的に</p>



<p class="wp-block-paragraph">「<strong>WordPressでクリックしたら画像やファイルをダウンロードできるリンクを作成する方法</strong>」</p>



<p class="wp-block-paragraph">を解説していきます。</p>



<div class="swell-block-capbox cap_box"><div class="cap_box_ttl"><span>ダウンロード用リンクを作成する手順</span></div><div class="cap_box_content">
<ul class="wp-block-list is-style-num_circle -list-under-dashed">
<li>ACFのファイルフィールドを設定</li>



<li>作成したファイルフィールドにファイルを設定</li>



<li>テンプレートファイルにソースコードを記述</li>
</ul>
</div></div>



<h3 class="wp-block-heading">① ACFのファイルフィールドを設定</h3>



<p class="wp-block-paragraph">まずはACFをインストールし、ファイルフィールドの設定を行います。</p>



<p class="has-text-align-center is-style-balloon_box2 wp-block-paragraph">実際の設定内容の例</p>



<figure class="wp-block-image size-full is-style-border size_xs"><img decoding="async" width="693" height="712" src="https://kekenta-it-blog.com/wp-content/uploads/2024/05/acf-file-field-app01.jpg" alt="ACFの「ファイル」フィールドの設定の様子" class="wp-image-7213" srcset="https://kekenta-it-blog.com/wp-content/uploads/2024/05/acf-file-field-app01.jpg 693w, https://kekenta-it-blog.com/wp-content/uploads/2024/05/acf-file-field-app01-292x300.jpg 292w" sizes="(max-width: 693px) 100vw, 693px" /></figure>



<h3 class="wp-block-heading">② 作成したファイルフィールドにファイルを設定</h3>



<p class="wp-block-paragraph">続いて投稿画面で、作成したファイルフィールドに実際にファイルを設定します。</p>



<p class="has-text-align-center is-style-balloon_box2 wp-block-paragraph">JPGファイルを設定した例</p>



<figure class="wp-block-image size-full is-style-border"><img decoding="async" width="652" height="185" src="https://kekenta-it-blog.com/wp-content/uploads/2024/05/acf-file-field-app04.jpg" alt="ACFの「ファイル」フィールドにjpgファイルを設定" class="wp-image-7210" srcset="https://kekenta-it-blog.com/wp-content/uploads/2024/05/acf-file-field-app04.jpg 652w, https://kekenta-it-blog.com/wp-content/uploads/2024/05/acf-file-field-app04-300x85.jpg 300w" sizes="(max-width: 652px) 100vw, 652px" /></figure>



<h3 class="wp-block-heading">③ テンプレートファイルにソースコードを記述</h3>



<p class="wp-block-paragraph">最後に、ダウンロード用リンクを出力したいテンプレートファイル内に以下のソースコードを記述します。</p>



<p class="is-style-balloon_box2 wp-block-paragraph">テキストリンクのみを表示する場合</p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-php" data-lang="PHP"><code>&lt;!-- フィールド名「file」を取得 --&gt;
&lt;?php $filefield = get_field(&#39;file&#39;); ?&gt;

&lt;!-- ファイルが設定されていたらダウンロード用リンクを設置 --&gt;
&lt;?php if(!empty($filefield)): ?&gt;
    &lt;a href=&quot;&lt;?php echo $filefield[&#39;url&#39;]; ?&gt;&quot; download&gt;ダウンロード &gt;&gt;&lt;/a&gt;
&lt;?php endif; ?&gt;</code></pre></div>



<figure class="wp-block-image size-full is-style-border"><img decoding="async" width="376" height="197" src="https://kekenta-it-blog.com/wp-content/uploads/2024/06/image-4.png" alt="" class="wp-image-7649" srcset="https://kekenta-it-blog.com/wp-content/uploads/2024/06/image-4.png 376w, https://kekenta-it-blog.com/wp-content/uploads/2024/06/image-4-300x157.png 300w" sizes="(max-width: 376px) 100vw, 376px" /></figure>



<p class="is-style-balloon_box2 wp-block-paragraph">プレビュー付き表示にしたい場合（こちらは画像ファイルでのみ可能）</p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-php" data-lang="PHP"><code>&lt;!-- フィールド名「file」を取得 --&gt;
&lt;?php $filefield = get_field(&#39;file&#39;); ?&gt;

&lt;!-- ファイルが設定されていたらダウンロード用のプレビュー付きリンクを設置 --&gt;
&lt;?php if(!empty($filefield)): ?&gt;
    &lt;a href=&quot;&lt;?php echo $filefield[&#39;url&#39;]; ?&gt;&quot; download&gt;&lt;img src=&quot;&lt;?php echo $filefield[&#39;url&#39;]; ?&gt;&quot;&gt;&lt;/a&gt;
&lt;?php endif; ?&gt;</code></pre></div>



<figure class="wp-block-image size-full is-style-border"><img decoding="async" width="382" height="360" src="https://kekenta-it-blog.com/wp-content/uploads/2024/06/image-3.png" alt="" class="wp-image-7648" srcset="https://kekenta-it-blog.com/wp-content/uploads/2024/06/image-3.png 382w, https://kekenta-it-blog.com/wp-content/uploads/2024/06/image-3-300x283.png 300w" sizes="(max-width: 382px) 100vw, 382px" /></figure>


<div class="swell-block-balloon"><div class="c-balloon -bln-left" data-col="gray"><div class="c-balloon__icon -circle"><img decoding="async" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-src="https://kekenta-it-blog.com/wp-content/uploads/2023/11/kekenta-icon-150x150.jpg" alt="" class="lazyload c-balloon__iconImg" width="80px" height="80px"><noscript><img decoding="async" src="https://kekenta-it-blog.com/wp-content/uploads/2023/11/kekenta-icon-150x150.jpg" alt="" class="c-balloon__iconImg" width="80px" height="80px"></noscript><span class="c-balloon__iconName">ケケンタ</span></div><div class="c-balloon__body -speaking -border-on"><div class="c-balloon__text">
<p>以上により、テキストあるいは画像をクリックすることで、そのファイルをダウンロードできるリンクの作成ができました！</p>
<span class="c-balloon__shapes"><span class="c-balloon__before"></span><span class="c-balloon__after"></span></span></div></div></div></div>


<h2 class="wp-block-heading">まとめ</h2>



<p class="wp-block-paragraph">いかがだったでしょうか。</p>



<p class="wp-block-paragraph">前置きこそ長くなってしまいましたが、手順自体は意外とシンプルで簡単だったのではないかと思います。</p>


<div class="swell-block-balloon"><div class="c-balloon -bln-left" data-col="gray"><div class="c-balloon__icon -circle"><img decoding="async" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-src="https://kekenta-it-blog.com/wp-content/uploads/2023/07/キリッ-150x150.jpg" alt="" class="lazyload c-balloon__iconImg" width="80px" height="80px"><noscript><img decoding="async" src="https://kekenta-it-blog.com/wp-content/uploads/2023/07/キリッ-150x150.jpg" alt="" class="c-balloon__iconImg" width="80px" height="80px"></noscript><span class="c-balloon__iconName">ケケンタ</span></div><div class="c-balloon__body -speaking -border-on"><div class="c-balloon__text">
<p>今回の方法はPDFファイルや画像など、サイトを訪れたユーザにダウンロードさせたいファイルがあるときに有効です。</p>
<span class="c-balloon__shapes"><span class="c-balloon__before"></span><span class="c-balloon__after"></span></span></div></div></div></div>


<p class="wp-block-paragraph">この記事の内容がお役に立ったなら何よりです。</p>



<p class="wp-block-paragraph">最後までご覧いただきありがとうございました！</p>



<p class="wp-block-paragraph"></p>
]]></content:encoded>
					
					<wfw:commentRss>https://kekenta-it-blog.com/wp-download-link/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
