Skip to content

Instantly share code, notes, and snippets.

@rahul3883 rahul3883/functions.php
Last active May 4, 2017

Embed
What would you like to do?
Remove 'All' tab from rtMedia's 'Media' tab and make 'Album' tab as a default tab
<?php
/**
* Change query var to fetch albums from database.
*
* @param array $query_vars Query vars.
* @return array Modified query vars.
*/
function rtm_change_query_var_cb( $query_vars ) {
global $wp_query;
if ( isset( $wp_query->query_vars['media'] ) && '' === $wp_query->query_vars['media'] ) {
$query_vars[ array_search( '', $query_vars, true ) ] = 'album';
}
return $query_vars;
}
add_filter( 'rtmedia_query_vars', 'rtm_change_query_var_cb' );
/**
* Remove 'All' tab from rtMedia and make 'Album' tab default.
*
* @param string $html Markup of 'All' tab.
* @return string Modified markup of 'All' tab.
*/
function rtm_remove_all_tab_cb( $html ) {
global $rtmedia_query;
if ( ! isset( $rtmedia_query->action_query->media_type ) && ! isset( $rtmedia_query->query['media_type'] ) ) {
$rtmedia_query->action_query->media_type = 'album';
$rtmedia_query->query['media_type'] = 'album';
}
return '';
}
add_filter( 'rtmedia_sub_nav_all', 'rtm_remove_all_tab_cb' );
@rahul3883

This comment has been minimized.

Copy link
Owner Author

commented May 4, 2017

Add the above code snippet to your theme's functions.php file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.