Custom Taxonomy Endpoint Pagination using paginate_links()
Custom Taxonomy Endpoint Pagination using paginate_links()
Custom Taxonomy Endpoint Pagination using paginate_links()
This is quite an interesting question (which I have upvoted, specially for your approach and research). The big curveball here is the first page of the query: You cannot set the query to return 0 posts on the first page By moving the page content of every page up by one page, you will loose … Read more
This is now working for me… for those of you having the same issue it turns out all the code was correct. The problem was WordPress is setup to show 10 posts per page by default which clashed with my query (limiting it to 2 posts) to fix the issue I changed the WordPress setting … Read more
Interesting question! I solved it by expanding the WHERE query with a bunch of post_title LIKE ‘A%’ OR post_title LIKE ‘B%’ … clauses. You can also use a regular expression to do a range search, but I believe the database won’t be able to use an index then. This is the core of the solution: … Read more
I solved it using the offset query parameter. This allowed me to edit the query in the pre_get_posts hook, and seems to be the cleanest way to do this, without a new query. Now the home page shows only one post, and page/2/ shows posts 2-11. All links keep working, no other modification is required. … Read more
Why your current code fails Your always getting the content of the first page, because the string of parameters passed to query_posts being encapsulated in single quotes prevents variables (as well as escape sequences for special characters other than $) to be expanded. query_posts(“post_type=videos&posts_per_page=9&paged=$paged”); would take care of that problem. query_posts(‘post_type=videos&posts_per_page=9&paged=’.$paged); would also. And finally, … Read more
Ok, I got there at the end. I couldn’t use WP_Query class as I really needed to have my own pretty big and complex SQL. Here is what I ended up having: In functions.php I have my custom SQL and logic for counting the values needed for the WP pagination logic: function vacancies_current( ){ global … Read more
Here is the code to get category based previous and next links on posts: <?php $post_id = $post->ID; // current post ID $cat = get_the_category(); $current_cat_id = $cat[0]->cat_ID; // current category ID $args = array( ‘category’ => $current_cat_id, ‘orderby’ => ‘post_date’, ‘order’ => ‘DESC’ ); $posts = get_posts( $args ); // get IDs of posts … Read more
You can get the current URL through home_url( $wp->request ). Try the example below: global $wp; // get current url with query string. $current_url = home_url( $wp->request ); // get the position where ‘/page.. ‘ text start. $pos = strpos($current_url , ‘/page’); // remove string from the specific postion $finalurl = substr($current_url,0,$pos); echo $finalurl;
This should get you really close. I haven’t tested it, but it’s nearly identical to a setup I’ve used a few times. /* * We start by doing a query to retrieve all users * We need a total user count so that we can calculate how many pages there are */ $count_args = array( … Read more