jchristopher / attachments

[WordPress Plugin] Attachments allows you to simply append any number of items from your WordPress Media Library to Posts, Pages, and Custom Post Types
wordpress.org/extend/plugins/attachments/
GNU General Public License v2.0
239 stars 78 forks source link

Setup Attachments for specific page-template? #130

Closed vol4ikman closed 9 years ago

vol4ikman commented 10 years ago

Setup Attachments for specific page-template (like, template-about.php) ?

How can I do that?

luandamasceno commented 10 years ago

If you want to limit a attachments instance to a single page, the _attachmentslocation{myinstance} may help you:

function my_attachments_location_limit( $val )
{
    global $post;

    // the post ID is 13 and you only want this instance to show up there
    return ( $post->ID == 13 ) ? true : false;
}

add_filter( 'attachments_location_my_attachments', 'my_attachments_location_limit' );

You can have your callback be as elaborate as you'd like, using any attributes WordPress has to offer at runtime.

jchristopher commented 9 years ago

Thank you @luandamasceno