$args = array(
'dropdown' => 0, // displays a list if set to 0, a dropdown list if set to 1 (default: 0)
'show_names' => 1, // displays language names if set to 1 (default: 1)
'display_names_as' => 'name', // either ‘name’ or ‘slug’ (default: ‘name’)
'show_flags' => 1, // displays flags if set to 1 (default: 0)
'hide_if_empty' => 1, // hides languages with no posts (or pages) if set to 1 (default: 1)
'force_home' => 0, // forces link to homepage if set to 1 (default: 0)
'echo' => 1, // echoes if set to 1, returns a string if set to 0 (default: 1)
'hide_if_no_translation' => 1, // hides the language if no translation exists if set to 1 (default: 0)
'hide_current' => 0, // hides the current language if set to 1 (default: 0)
'post_id' => null, // if set, displays links to translations of the post (or page) defined by post_id (default: null)
'raw' => 0, // use this to create your own custom language switcher (default:0)
);
pll_the_languages( $args );
query_posts,
он повторно запускает запросы в базу и переопределяет глобальный объект WP_Query
. Из офф. документации:Note: This function will completely override the main query and isn’t intended for use by plugins or themes. Its overly-simplistic approach to modifying the main query can be problematic and should be avoided wherever possible. In most cases, there are better, more performant options for modifying the main query such as via the ‘pre_get_posts’ action within WP_Query.
get_posts или pre_get_posts
- Это обертка WP_Query
, которая упрощает выборку постов и не изменят глобальные переменные, в ней еще определены некоторые дефолтные аргументы из-за чего выборку сделать проще.WP_Query
add_filter('nav_menu_css_class' , 'special_nav_class' , 10 , 2);
function special_nav_class($classes, $item){
$classes[] = 'your-custom-class';
return $classes;
}
Object.filter = function( obj, filtercheck) {
let result = {};
Object.keys(obj).forEach((key) => { if (filtercheck(obj[key])) result[key] = obj[key]; })
return result;
};
let carsFiltered = Object.filter(cars, filterFunc);