Default selection
-
Hallo, how can i make a default selection Instead filter by to:
Not in category.Could you please give me hint what edit, even in core file.
Thank you very much.
Martin
-
Hello Martin,
Sorry, your question is not clear to me. Can you please describe your need in more details? What do you mean by “default selection”?
Best,
-NadiaThanks for reply,
By defauld, in media libraly when install your script i have all images,
i would like have selected by defalt: –NOT IN MEDIA CATEGORY–
Thank you for help.
Sincerely Martin.
I see now, thanks. The simple solution exists for the grid mode and media popups:
$( document ).ready( function() { $('#media-attachment-media_category-filters').val('not_in').change(); });For the list mode things get complicated.
Best,
-NadiaGrid mode is enough for me.
Please what file to edit?
I tryed edit:
eml-media-grid.js
eml-medialibrary-options.jsbut no success.
COuld you hint me a little.
Thank you for you time.
Martin
or this will be also OK:

Martin,
You should add a JS file with this custom code to your theme folder, for example:
( function( $ ) { $( document ).ready( function() { $('#media-attachment-media_category-filters').val('not_in').change(); }); })( jQuery );You should also enqueue the script in your theme functions.php like this:
add_action( 'wp_enqueue_scripts', 'YOUR_PREFIX_enqueue_scripts' ); function YOUR_PREFIX_enqueue_scripts() { wp_enqueue_script( 'eml-customization', get_template_directory_uri() . '/eml-customization.js' ); }Best,
-NadiaHallo,
i tryed create file:
not_in_c.js
put this file into my theme folder. Put into file the first code you posted.
The second code i put into functions.php and changed:
add_action( 'wp_enqueue_scripts', 'not_in_c_enqueue_scripts' ); function not_in_c_enqueue_scripts() { wp_enqueue_script( 'not_in_c', get_template_directory_uri() . '/not_in_c.js' ); }Is prefilx same as first part of created js.file?
And this way it now work for me.Martin,
The prefix is totally up to you. Glad to know you have managed to make it work.
Best,
-NadiaHallo,
unfortunatelly, it does not work for me. Still same. All images i see.I was little confused, so I though that something with prefix i made wrong.
Sincerely Martin
Hello Martin,
Sorry,
(1) better use
$(window).on( 'load', function(){} );( function( $ ) { $( window ).on( 'load', function() { $('#media-attachment-media_category-filters').val('not_in').change(); }); })( jQuery );(2) should be
admin_enqueue_scriptsadd_action( 'admin_enqueue_scripts', 'not_in_c_enqueue_scripts' ); function not_in_c_enqueue_scripts() { wp_enqueue_script( 'not_in_c', get_template_directory_uri() . '/not_in_c.js' ); }Best,
-NadiaHallo,
now it works like a charm.
Thank you very much for your time.
All the best.
Sincerely Martin
The topic ‘Default selection’ is closed to new replies.
