• Been trying to figure how to allow users to choose the number of posts to display on my homepage. At the very least I would love to give them the option to choose to show say 9,15,or 25 posts. Any help or plugin that anybody could recommend will be much appreciated!

Viewing 6 replies - 1 through 6 (of 6 total)
  • How do you envisage it working? You could parse a value to a wp_Query or query_posts that the user selects from a drop down list or radio buttons?

    Thread Starter steta7

    (@steta7)

    Thanks for the reply g3legacy. I was hoping to have something like you mentioned (a drop down where the user can select the number of posts show on the homepage). I’m new to development and the Loop. Can you give me more insight on how exactly to utilize the query_posts to make a dropdown?

    Well, personally I’d start with a default number of posts and have the drop down available. If the user selects a value and hits “submit” you could parse the value to the query and reload the page. I’m not 100%, I’m not a serious developer, but I think I could do this ok using this method. Have you used query posts at all? Query posts modifies the main loop on a page, this for example “query_posts( ‘posts_per_page=5’ );” means only 5 posts will show in the loop.

    Thread Starter steta7

    (@steta7)

    Yes, I’m definitely not a developer and have just been trying to learn things on the go lol. I have used and am familiar with query_posts however I just don’t know I can “connect” the choice the user makes using the drop down below to the posts_per_page # (i.e. if user selects option “9”, how do i get the query_posts(‘posts_per_page=9’).

    <form>
    <select name=”show_posts”>
    <option value=”9″>9</option>
    <option value=”15″>15</option>
    <option value=”21″>21</option>
    <option value=”27″>27</option>
    </select>
    </form>

    Again thanks for your insight and help, and apologies if I seem clueless ( which for the most part I am ?? )

    I would look up some info on $_POST. You should be able to send the value using a form like you’ve written. When loading the page i’d do an IF statement and see if $_POST[‘your_var’] has a value, if it does, parse it to the query_posts like this query_posts(‘posts_per_page=$your_var’); – or that’s the general idea I have in my mind haha.

    Thread Starter steta7

    (@steta7)

    Ok Thanks a lot g3legacy!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How to allow users to choose # of posts to display’ is closed to new replies.