New answers tagged

0

Have you considered using Javascript/jQuery to initially hide the child entries and then display them only when the parent term is clicked? This behavior could be set up as a toggle to allow child entries to become hidden when the parent is clicked.


0

The way WordPress handles this by default is not ideal - they provide the WP_Query object - through that, you can add whatever filters you like but there's no easy way I know of to create adaptive filters. That's one of the reasons I created my Faster Woo Widgets plugin - it does exactly what you're looking for - it lets you create category widgets with ...


0

Doing it this way works flawlessly, and makes more sense, as you basically only need to assure that a term has a language once it's assigned to a new / existing post: add_action( 'save_post', function( $post_ID ) { if ( ! function_exists( 'pll_set_term_language' ) || ! function_exists( '...


0

wp_insert_post_data is applied before the post data are inserted to the database. use the save_post hook instead to set the custom taxonomy terms. That was it. Thanks Sally for the recommendation.


1

Yes, as the documentation for wp_terms_checklist() stated, you can use the walker argument (which is part of the $args parameter for the wp_terms_checklist_args hook) to use a custom walker which modifies the output of the Category checklist generated by wp_terms_checklist(), e.g. the one in the "Categories" meta box on wp-admin/post.php. Example ...


2

Easiest way to find terms of many posts is to use wp_get_object_terms function $your_post_ids = array(12, 13, 18, 22, 343, 5644); $your_taxonomy = 'location' //you can set many as array $terms = wp_get_object_terms ( $your_post_ids, $your_taxonomy);


1

You can use pre_get_posts hook to modify the main query, or any WP_Query for that matter. For example like this, add_action( 'pre_get_posts', function($query) { // target only public category main query if ( is_admin() || ! $query->is_main_query() || ! is_category() ) { return;...


0

You can use the wp_robots filter to manipulate the robots meta tag as needed. And as you're checking against a taxonomy term you can use the has_term() helper conditional to make your code look a litte nicer. (A post can be passed to has_term() as the 3rd parameter, but if it is not passed then the function checks against the current post.) add_filter( '...


Top 50 recent answers are included