Tag Info

New answers tagged

1

You can filter any WP query using pre_get_posts(). The (sometimes) tricky part is that it is run against all queries of WP so you need to pinpoint your query using WP conditionals (is_admin(), is_page(), is_archive(), etc... ). You'll find a few useful examples on that page, too.


0

Yes, I think the only way is to remake the loop, the slightly tricky bit being to make the $args array the same as get_posts()'s defaults: $args = array( 'post_type' => 'event', 'posts_per_page' => 6, 'post_status' => 'publish', // If post_type 'attachment' then 'post_status' => 'inherit' 'orderby' => 'date', 'order' => 'DESC', ...


0

I modify wordpress query from functions.php: //for "IS_PAGE" conditions, pre_get_posts doesnt work (it's WORDPRESS behaviour) //so, inside `add_action('wp....` use `add_filter(posts_where.....` OR modify "PAGE" query directly into template file add_action('pre_get_posts','myf88');function myf88($query) { if ( !is_admin() && ...


0

For testing purposes in your functions.php file, try this - add_action('init', 'my_test_get_all_bands', 99); function my_test_get_all_bands(){ echo '<pre>'; print_r(get_all_bands()); echo '<pre>'; } As I was attempting to say in my comment to your question (and as Pieter Goosen explained rather better), if your taxonomies have not yet been ...


0

the_posts_navigation() is simply a wrapper function for get_the_posts_navigation() which issimply a wrapper function for paginate_links. The first two functions uses the the same exact parameters that is being used by paginate_links and actually passes it to the latter function as well get_the_posts_navigation() and the_posts_navigation() is good new ...


0

This function uses the get_the_posts_pagination() which uses the GLOBAL wp_query to setup the paginate_links() function, so I believe that doesn't work for get_posts. https://developer.wordpress.org/reference/functions/get_the_posts_pagination/ Try use the function paginate_links() by itself or the function posts_nav_link() PS: Make sure you use ...


0

The 'posts_per_page' => -1, and 'nopaging' => true, shouldn't be in your tax_query params. That might be what's throwing it off. Try: $args = array( 'post_type'=>'gpp_prod', 'orderby' => 'title', 'order' => 'ASC', 'posts_per_page' => -1, 'nopaging' => true, ); and: $args['tax_query'] = array( array( ...


0

It looks like you're placing the posts_per_page parameter in a wrong place under the tax_query part of get_posts. You could try for example: $args = array( 'posts_per_page' => -1, 'post_type' =>'gpp_prod', 'orderby' => 'title', 'order' => 'ASC' ); if( $category > 0 ){ $args['tax_query'] = array( ...



Top 50 recent answers are included