WordPress.org

Support

Support » Plugins and Hacks » WP-Paginate » [Plugin: WP-Paginate] posts_per_page with custom queries

[Plugin: WP-Paginate] posts_per_page with custom queries

  • Hal

    @halburgissnet

    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.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Eric Martin

    @emartin24

    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.

    Hal

    @halburgissnet

    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.

    Hal

    @halburgissnet

    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.

    Hal

    @halburgissnet

    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.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Plugin: WP-Paginate] posts_per_page with custom queries’ is closed to new replies.
Skip to toolbar