WordPress.org

Ready to get started?Download WordPress

Forums

WP-Paginate
posts_per_page with custom queries (5 posts)

  1. Hal
    Member
    Posted 3 years ago #

    I am doing search queries with custom fields and other custom tables. For example:

    SELECT DISTINCT wposts.*
        FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta
        WHERE wposts.ID = wpostmeta.post_id
        AND
        (
        	wpostmeta.meta_value regexp '$s'
    	OR wposts.post_title regexp '$s'
        )
        AND wposts.post_status = 'publish'
        ORDER BY wposts.post_date

    I have the $paged variable set, but I am getting the whole result in one huge page, like 100+ posts. Is there a way to manually set the posts_per_page value? Some variable maybe? wp-paginate is not handling this right now.

    Thanks.

  2. Eric Martin
    Member
    Plugin Author

    Posted 3 years ago #

    Is it not possible to use the query_posts() function? If you do a custom query, you are going to have to make sure to set all of the internal WordPress values that WP-Paginate needs.

  3. Hal
    Member
    Posted 3 years ago #

    Is it not possible to use the query_posts() function?

    No.

    If you do a custom query, you are going to have to make sure to set all of the internal WordPress values that WP-Paginate needs.

    That's what I am asking. I don't see what those are. I assume I'll need to do some LIMIT clause stuff with the query.

    Thanks.

  4. Hal
    Member
    Posted 3 years ago #

    As a follow up, if I set the mysql LIMIT to something like 0,10, then wp-paginate only sees 10 items, and doesn't see a need to paginate, and doesn't do anything, of course. And if I don't use the LIMIT clause, I apparently get all posts. The pagination links are there, but they are fubar because all the posts are actually on the first page.

    I can wrestle this to the ground, but was hoping somebody had already been here. Thanks.

  5. Hal
    Member
    Posted 3 years ago #

    Never could get this to work correctly, so I went back to the old fashioned way and did my own pagination. Not sure if its because of the way I am doing the query or something else, but I never could get it to work at all. Nice idea, though.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic