<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.1" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
		>
	<channel>
		<title>WordPress Ideas &#187; Topic: archive-attachment.php</title>
		<link>https://wordpress.org/ideas/topic/archive-attachmentphp</link>
		<description>WordPress Ideas &#187; Topic: archive-attachment.php</description>
		<language>en-US</language>
		<pubDate>Sat, 10 Jun 2017 11:53:48 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.1</generator>
				<atom:link href="https://wordpress.org/ideas/rss/topic/archive-attachmentphp" rel="self" type="application/rss+xml" />

		<item>
			<title>entruempler on "archive-attachment.php"</title>
			<link>https://wordpress.org/ideas/topic/archive-attachmentphp#post-31886</link>
			<pubDate>Sat, 27 May 2017 11:12:38 +0000</pubDate>
			<dc:creator>entruempler</dc:creator>
			<guid isPermaLink="false">31886@https://wordpress.org/ideas/</guid>
			<description><![CDATA[<p>@khodadadi: Thanks a lot, your code is working really nice to display the file mime type, great idea, very well done!
</p>]]></description>
					</item>
		<item>
			<title>khodadadi on "archive-attachment.php"</title>
			<link>https://wordpress.org/ideas/topic/archive-attachmentphp#post-31047</link>
			<pubDate>Tue, 22 Nov 2016 08:50:47 +0000</pubDate>
			<dc:creator>khodadadi</dc:creator>
			<guid isPermaLink="false">31047@https://wordpress.org/ideas/</guid>
			<description><![CDATA[<p>Dear @powerbuoy and @parkerarrowfotografie<br />
Let me ask you this question: Do you use the_permalink() function in the main loop for print the files' urls? If your answer is yes, then use wp_get_attachment_url() function for this purpose.<br />
And finally if you want to display special file mime type in your media archive page you can use codes like below.<br />
<pre><code>function dt_change_pre_get_posts_arguments($query){
	if( $query-&#62;is_main_query() ){
		if( $query-&#62;is_post_type_archive(&#039;attachment&#039;) ){
			$query-&#62;set(&#039;post_mime_type&#039;, &#039;image/jpeg&#039;);
			$query-&#62;set(&#039;post_status&#039;, &#039;any&#039;);
		}
	}
}
add_action( &#039;pre_get_posts&#039;, &#039;dt_change_pre_get_posts_arguments&#039;);</code></pre>]]></description>
					</item>
		<item>
			<title>parkerarrowfotografie on "archive-attachment.php"</title>
			<link>https://wordpress.org/ideas/topic/archive-attachmentphp#post-30800</link>
			<pubDate>Tue, 27 Sep 2016 19:49:16 +0000</pubDate>
			<dc:creator>parkerarrowfotografie</dc:creator>
			<guid isPermaLink="false">30800@https://wordpress.org/ideas/</guid>
			<description><![CDATA[<p>Awesome! That really is simple but I just wasn't able to figure that out.</p>
<p>I need it as an upload for photographs and this really helps. Nevertheless I have the same issue than powerbuoy and don't want all the photos / attachments which are uploaded in a specific post to have the URL as a prefix. Any ideas ?
</p>]]></description>
					</item>
		<item>
			<title>powerbuoy on "archive-attachment.php"</title>
			<link>https://wordpress.org/ideas/topic/archive-attachmentphp#post-30794</link>
			<pubDate>Sat, 24 Sep 2016 14:32:13 +0000</pubDate>
			<dc:creator>powerbuoy</dc:creator>
			<guid isPermaLink="false">30794@https://wordpress.org/ideas/</guid>
			<description><![CDATA[<p>@khodadadi this looked really promising, but I can't get it to work at all.</p>
<p>I've added the code and confirmed that it runs (I var_dumped the whole $args array and it contains has_archive and slug) but the URLs refuse to change.</p>
<p>What's more, images uploaded to a specific post will have that post's URL as a prefix. I'd like a solution where every image uploaded ends up at /images/the-image/ regardless.
</p>]]></description>
					</item>
		<item>
			<title>khodadadi on "archive-attachment.php"</title>
			<link>https://wordpress.org/ideas/topic/archive-attachmentphp#post-30685</link>
			<pubDate>Sat, 27 Aug 2016 07:44:36 +0000</pubDate>
			<dc:creator>khodadadi</dc:creator>
			<guid isPermaLink="false">30685@https://wordpress.org/ideas/</guid>
			<description><![CDATA[<p>Hi Pancho Perez<br />
I know that the topic is for 3 years ago and I don't know whether you find a solution to this problem or not.<br />
But as I was searching for solution and I could not find anything on the web, I solved it on my own and I want to share it here.</p>
<p>The solution is very simple. WordPress registers the default post types (post,page,attachment and etc) with arguments that don't allow us to have archive pages for these post types. </p>
<p>you should add archive-{post_type}.php template files to your template folder (archive-post.php or archive-attachment.php) and then add this code to your functions.php file:</p>
<pre><code>function dt_change_default_post_type_args($args, $post_type){
	if($post_type == &#039;attachment&#039;){
		$args[&#039;has_archive&#039;] = true;
		$args[&#039;rewrite&#039;] = array(&#039;slug&#039;=&#62;&#039;media&#039;);
	}
	if($post_type == &#039;post&#039;){
		$args[&#039;has_archive&#039;] = true;
		$args[&#039;rewrite&#039;] = array(&#039;slug&#039;=&#62;&#039;blog&#039;);
	}
	return $args;
}
add_filter( &#039;register_post_type_args&#039;, &#039;dt_change_default_post_type_args&#039;, 10, 2 );</code></pre>
<p>you can change rewrite argument to have your own slug or just set it boolean true to use post type default slug.<br />
at last remember to save your permalink settings again after saving the functions.php file.
</p>]]></description>
					</item>
		<item>
			<title>Mike on "archive-attachment.php"</title>
			<link>https://wordpress.org/ideas/topic/archive-attachmentphp#post-29652</link>
			<pubDate>Mon, 01 Feb 2016 12:50:13 +0000</pubDate>
			<dc:creator>Mike</dc:creator>
			<guid isPermaLink="false">29652@https://wordpress.org/ideas/</guid>
			<description><![CDATA[<p>I could use this kind of functionality immensely!
</p>]]></description>
					</item>
		<item>
			<title>Pancho Perez on "archive-attachment.php"</title>
			<link>https://wordpress.org/ideas/topic/archive-attachmentphp#post-25211</link>
			<pubDate>Sat, 17 Aug 2013 19:07:21 +0000</pubDate>
			<dc:creator>Pancho Perez</dc:creator>
			<guid isPermaLink="false">25211@https://wordpress.org/ideas/</guid>
			<description><![CDATA[<p>Now is the thirdth project I need ot create a Template to list all files uploaded to the Media Library, to found a solution I have to serach and try to much. </p>
<p>Why we don´t have an option to use archive-attachment.php as we have attachment.php for single attachments?</p>
<p>Then it could be easy to filter the files using <code>post_mime_type</code>.</p>
<p>Other could be filtered the attachments if they are inside a post or not.</p>
<p>I know also need to create a new url like wordpress/attachment or /attachments.</p>
<p>Then make a gallery image or a download files archive page could be very very easy :)
</p>]]></description>
					</item>

	</channel>
</rss>
