tax_query: Order by slug?

If I understand your scenario, your events are in the right order but your semesters are not. If you change line 4 $terms = get_terms(‘semesters’); to $terms = get_terms(‘semesters’, array( ‘orderby’ => ‘slug’ ) ); that should put the semesters in the order you’re looking for. ‘order’ defaults to ASC, which is what you need … Read more

How to correctly pass values to wpdb->prepare()?

I’ve found an answer by myself.. (sample code) $args_array = array($post_type); $term_slugs = array(‘foto’, ‘video’); // create a string like ‘%s, %s’ ecc $placeholders = implode(‘, ‘, array_fill(0, count($term_slugs), “%s”)); $term_query = “t.slug IN ($placeholders) “; $args_array = array_merge($args_array, $term_slugs); $ids = $wpdb->get_results($wpdb->prepare(” SELECT m.meta_value FROM ” . $wpdb->prefix . “posts p INNER JOIN ” … Read more

Query post from all category with same tag on 1 pages

This will help to get the category post on tag archive page. Let me know. <?php $current_tag = single_tag_title( $prefix = ”, $display = false ); $categories = get_categories( array(‘hide_empty’ => TRUE) ); foreach($categories as $category) { ?> <?php $args=array( ‘posts_per_page’ => -1, ‘tag’ => $current_tag, ‘cat’ => $category->term_id, ); $the_query = new WP_Query( $args … Read more

Pagination is broken and I need help fixing it

I’m not sure why the first page works but the second doesn’t, though this may be a hint toward the problem. Toward the bottom of the category template page you have the following: if (function_exists(custom_pagination)) { custom_pagination($custom_query->max_num_pages,””,$paged); } If you review the above, there is a variable called $custom_query. This looks like it’s a WordPress … Read more

How to find a post id using the post_excerpt?

You can get the post ID from the excerpt, but as far as I can tell, WP_Query doesn’t support this (very well), so you need to write a custom WPDB query. function get_post_id_by_excerpt($excerpt) { global $wpdb; $result = $wpdb->get_row( $wpdb->prepare(“SELECT ID FROM {$wpdb->prefix}posts WHERE post_excerpt LIKE %s”, $excerpt) ); return $result; } For this to … Read more

pre_get_posts Remove tax_query Completely

This fixed it! 🙂 Hat-tip gmazzap for the useful info: Obliterate the main query and replace it function wpse_286813_omit_all( $query_vars ){ // triggered also in admin pages if ( is_admin() ) return $query_vars; if( !empty($query_vars[‘taxo’]) && $query_vars[‘taxo’] === ‘all’ ){ $query_vars[‘taxo’]=”; } return $query_vars; } add_filter( ‘request’, ‘wpse_286813_omit_all’ );

how to link to detail page(single.php?) in a wp_loop

Replace with below code : <?php $args = …..; $query = new WP_Query($args); while($query->have_posts() ) : $query->the_post(); ?> <div class=”each”> <h4><a href=”https://wordpress.stackexchange.com/questions/289892/<?php the_permalink();?>” title=”<?php the_title_attribute();?>”><?php the_title();?></a></h4> </div> <?php endwhile; wp_reset_query(); ?>