Support » How-To and Troubleshooting » Overriding posts_per_page in 1.5

Overriding posts_per_page in 1.5

  • 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.

Viewing 7 replies - 1 through 7 (of 7 total)
  • 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)

    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

    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.

    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).

    Not an answer, but a possible alternative:

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

    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.

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

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Overriding posts_per_page in 1.5’ is closed to new replies.