WordPress.org

Forums

Overriding posts_per_page in 1.5 (8 posts)

  1. elvix
    Member
    Posted 10 years ago #

    I want to display a single post on a custom template (to get a powerpoint/slideshow-like presentation). There's almost no info I can find on how to do this within the 1.5 theme system (adding a custom template), so instead I figured I would just hack up a new page and drop it in the main WP directory.

    I tried adding a "$posts_per_page = 1;" above the 'wp-blog-header' line, but I get a SQL error. ($cat seems to work fine, however.)

    I don't want to affect the number of posts displayed on the other pages (home, category, archives, etc.). They are fine. I just want to override it in this one case (this custom template).

    I realize I could simple hack the loop and stop after one iteration, but it seems stupid not to try and limit the DB query if possible.

  2. elvix
    Member
    Posted 10 years ago #

    For clarity: setting $posts_per_page =1 does limit the page to 1 post. However, I'm getting a MYSQL syntax error. (Obviously, I don't get this error normally)

    Quoted:
    WordPress database error: [You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY post_date ASC LIMIT 0,1' at line 1]

    SELECT ID,post_title FROM wp_posts WHERE post_date > '' AND post_date < '2005-02-10 16:55:40' AND post_status = 'publish' AND ID != ORDER BY post_date ASC LIMIT 0,1

  3. tcloer
    Member
    Posted 10 years ago #

    Hm - why don't you just set up a new "page" (Write/Page)? That's one of the main new features in 1.5 and exactly conceptioned for your purpose, i suppose.

  4. elvix
    Member
    Posted 10 years ago #

    actually, i don't want to display a specific post, rather one post (vs. several, i.e. 10 or 15). I'm trying to generate a slideshow of posts: one post displayed with the nav links (prev and next posts).

  5. Michael Adams (mdawaffe)
    Member
    Posted 10 years ago #

    Not an answer, but a possible alternative:

    Create a Page, as tcloer suggests, with multiple pages (using the <!--nextpage--> QuickTag).

  6. Nick Momrik
    Inactive
    Posted 10 years ago #

    elvis,
    I'm currently looking into this myself. I want my archives (using a custom template) to display everything for a requested time period, not just whatever is set in the admin options. I'll post back if I find an answer.

  7. Nick Momrik
    Inactive
    Posted 10 years ago #

  8. Nick Momrik
    Inactive
    Posted 10 years ago #

    In your case elvix, I thing you should be able to add a posts_per_page=1 instead of nopaging=1

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.