• Hey, i want to share my solution to connect the attachment plugin only to a specific page template.
    Thanks to: https://wordpress.stackexchange.com/questions/18122/toggle-admin-metabox-based-upon-chosen-page-template

    Put his code in functions.php

    add_action('admin_enqueue_scripts', 'my_admin_script');
    function my_admin_script()
    {
        wp_enqueue_script('my-admin', get_bloginfo('stylesheet_directory').'/js/my-admin.js', array('jquery'));
    }

    And make a new js-file like this.
    In my example; the ‘template-contact.php’ (Contact template) is showing the attachment plugin.

    (function($){
    $(document).ready(function() {
    
        var $page_template = $('#page_template')
            ,$metabox = $('#attachments-my_attachments_temp'); // For example
    
        $page_template.change(function() {
            if ($(this).val() == 'template-contact.php') {
                $metabox.show();
            } else {
                $metabox.hide();
            }
        }).change();
    
    });
    })(jQuery);

    Hope this helps for somebody too.

    https://www.ads-software.com/extend/plugins/attachments/

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Show attachments on specific page template’ is closed to new replies.