Tag Info

Hot answers tagged

3

You can try the following (untested): Setup the query arguments #1: (today) //----------------- // Query part #1: //----------------- $args1 = array( 'post_type' => 'post', 'orderby' => 'comment_count', 'ignore_sticky_posts' => 1, 'date_query' => array( array( ...


3

Please do not use showposts it got replaced by posts_per_page ages ago. Personally I would add the arguments to the WP_Query like shown below, additionally pagination should work like shown below: $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1; $args = array( 'post_per_page' => 4, 'paged' => $paged, ); $query = ...


1

Here is the query format for displaying author posts with pagination. You will have to also add paged argument to paginate. <?php // fix pagination issue if ( get_query_var('paged') ) { $paged = get_query_var('paged'); } elseif ( get_query_var('page') ) { $paged = get_query_var('page'); } else { $paged = 1; } $args = array( ...


1

Because the global $wp_query represents the query for the current page (the "main" query) and is completely separate from your custom $author_query. If you want to use pagination functions, you can "fake it" by temporarily setting $wp_query to your custom query, and then resetting afterwards: global $wp_query, $wp_the_query; $wp_query = $author_query; // ...


1

From the info you have given in your post, I believe you are using a custom page.php template here Here is the the reasons you get the output as stated: The main query executes on each and every page that is loaded. The main query is very specific for every type of template. $wp_query is the super global used by the main query To test the how unique the ...


1

You should probably return the user to the first page of results following a search in all scenarios, to be consistent. If you did need to check though you can use the following: $wp_query->max_num_pages; So if there's only 2 pages and you're on page 3 then you need to redirect to the start.


1

EDIT Try this code: remove_action( 'genesis_loop', 'genesis_do_loop' ); add_action( 'genesis_loop', 'sk_do_loop' ); function sk_do_loop(){ global $wp_query; $temp_query = $wp_query; // Fix for the WordPress 3.0 "paged" bug. $paged = 1; if ( get_query_var( 'paged' ) ) { $paged = get_query_var( 'paged' ); } if ( get_query_var( 'page' ) ) { $paged = ...


1

Your problem might be related to 5. The previous_posts_link only accepts one valid parameter, and that is $label, you are passing two. Secondly, the next_posts_link does accept the second parameter $max_pages. Here you ara passing a value of 5, which overrides $wp_query->max_num_pages. So you are telling Wordpress there are 5 pages, regardless of the ...


1

Before we begin, I must point out the following: You're using a file in your theme to send AJAX requests to, don't do this, there are security implications. Instead, use the WP AJAX API, you'll be able to remove half the code and make it work without having to change the URL everytime your site moves You used query_posts to make your query, this is almost ...


1

There where one or two problems with the code that I sorted out Big changes $number_of_terms = count( get_terms( '100list' ) ); is replaced by $number_of_terms = wp_count_terms( '100list' );. The reason is that wp_count_terms is already there to return the term count natively get_categories is replaced by get_terms as get_terms accepts the offset ...


1

I've realised what the issue was... some of my posts were generated (for development purposes) using bulk creator which appears to not create a complete post! When I create a post manually using the WP backend my code works fine, thanks for the suggestions anyway guys!


1

When you are on a taxonomy page, you can get the parent from the term being displayed by using the following code with get_queried_object. See get_terms for the objects that are returned $queried_object = get_queried_object('term'); $term = $queried_object->parent; To get the taxonomy, you can simply just add $tax = $queried_object->taxonomy; ...


1

You can filter the content earlier than these plugins and add the navigation there. Remove wp_link_pages() from the template, and add the following code to the theme: add_filter( 'the_content', function( $content ) { return $content . wp_link_pages( [ 'echo' => FALSE ] ); }, -1 ); // Lower number = higher priority.



Only top voted, non community-wiki answers of a minimum length are eligible