Tag Info

New answers tagged

0

You can use a tax query with include_children set to false: $query = new WP_Query( array( 'tax_query' => array( array( 'taxonomy' => 'category', 'field' => 'slug', 'terms' => 'your-category-slug', 'include_children' => false, ), ), ) );


0

After a lot of guess work and research I've managed to come up with a simple solution. function column_orderby( $vars ) { $vars['orderby'] = 'date'; $vars['order'] = 'desc'; return $vars; } add_filter( 'request', 'column_orderby' ); This will sort all of the columns by 'date' as well as order them by 'desc'! Hope it helps anyone in the same ...


1

You can store the counts as key and link a value and sort them before display like this : $sort_tab = array(); while (have_posts()) : the_post(); if ( has_post_thumbnail() ) { the_post_thumbnail( array(40,40) ); } $url = get_the_permalink(); $json = file_get_contents( ...


0

EDIT: Well, it seems the following approach is a bit DB consuming. Pieter Goosen posted a very interesting alternative. Since this approach has already been accepted as a correct answer I don't know, it it is possible to mark this question still as a duplicate. I flagged my answer so a moderator might have a look. Thanks. I first collect all data in an ...


0

Here is example: add_action('pre_get_posts','search_filterr');function search_filterr($query) { if ( !is_admin() && $query->is_main_query() ) { if ( $query->is_search ) { $query->set('post_type', array('post','custom-posttt-too') ); $query->set('category__in', 999 ); <------ ...


0

You can use WP_Object_Cache combined with a persistent cache plugin or you can use Transient API. WP_Object_Cache: // Random post link function randomPostlink(){ $cache = wp_cache_get( 'random_tip_link' ); if( $cache ) { echo $cache; } else { ob_start(); $RandPostQuery = new ...



Top 50 recent answers are included