pagination functions are not working
pagination functions are not working
pagination functions are not working
Use pre_get_posts to exclude the categories you don’t want to display in the loop. function exclude_posts_from_specific_category( $query ) { if ( $query->is_home() && $query->is_main_query() ) { $query->set( ‘cat’, ‘-2’ ); } } add_action( ‘pre_get_posts’, ‘exclude_posts_from_specific_category’ ); Or create a new WP_Query and use the Category Parameters. $args = array( ‘category__not_in’ => 2 , ‘category__in’ => … Read more
I’ve came up with the not perfect solution to this: Because I am using term_taxonomy_id I can just add all the IDS and remove the taxonomy specification like this: ‘tax_query’ => array( array( ‘field’ => ‘term_taxonomy_id’, ‘terms’ => array(…all ids…) ) ) And it works! This is a quick solution, although it will work in … Read more
Having same problem. Ended up with the following codes global $woocommerce_loop; $woocommerce_loop[‘paged’] = (isset($woocommerce_loop[‘paged’])) ? $woocommerce_loop[‘paged’] : 1; $woocommerce_loop[‘total’] = $custom_query->found_posts; $woocommerce_loop[‘post_count’] = $custom_query->post_count; $woocommerce_loop[‘per_page’] = $per_page; $woocommerce_loop[‘total_pages’] = ceil($custom_query->found_posts/$per_page); $woocommerce_loop[‘current_page’] = $args[‘paged’];
ob_start() This function will turn output buffering on. While output buffering is active no output is sent from the script (other than headers), instead the output is stored in an internal buffer. ob_get_clean() Gets the current buffer contents and delete current output buffer. try this code function qut_research_subpages_shortcode_frontend($atts) { $args = array( ‘post_type’ => ‘page’, … Read more
You could use the get_search_query(); function. More in developer.wordpress
We all know that ignore_sticky_posts is used to exclude sticky post from your custom query. – No, this assumption is wrong. What ignore_sticky_posts means: Even though in natural English, ignore_sticky_posts sounds like WordPress should ignore all sticky posts from the query, in reality that is not what WordPress does. Instead, you should read ‘ignore_sticky_posts’ => … Read more
WP_Query doesn’t work when url parameter is added
What you want to do is access the query_vars and use them. Base code: Page to access the fields $custom_field = get_query_var(‘custom_field’); var_dump($custom_field); And the function or custom plugin to save the magic: add_filter( ‘query_vars’, ‘my_custom_query_vars’ ); function my_custom_query_vars( $vars ) { $vars[] = ‘custom_field’; $vars[] = ‘custom_awesome_field’; return $vars; } yourawesomesite.awesome/?custom_field=white string ‘white’ (length=5)
I’m not fun of helper functions so I would write it like this: $args=array( ‘post_type’ => ‘post’, ‘posts_per_page’ => ’20’, ‘post_status’ => ‘publish’, ‘order’=>’DESC’, ‘orderby’=>’ID’, ); $query = new WP_Query( $args ); if ( $query->have_posts() ) { while ( $query->have_posts() ) { $query->the_post(); $current_id = $post->ID; echo the_field(‘field1’, $current_id); } wp_reset_postdata(); } else { // … Read more