• jojo0507

    (@jojo0507)


    How do I check how many posts have been retrieved (or will be retrieved) on the root of the wp blog, i.e. by index.php?

    I am doing some styling, and just want to get the number of posts retrieved so I can generatr a table on the fly.
    The number of rows in the table should be the same as the number of posts that were retrieved in index.php or the number of comments retreived in single post mode.

    Can I do the same thing to check comments retrieved/recieved per single post? If so what is the function?

    I am populating this variable in my header.php, BEFORE index.php, single.php etc have been executed, I believe. Is that relevant?

    (If you know the answer, would you be able to point me to a reference (codex) about these functions? I am struggling to find my way around the WP site and I haven’t been able to find a listing of all funcions so far.)

    Hope somembody can help?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Dgold

    (@dgold)

    Normally you pre-set the number of posts that will be called on the home-page. You set this in your WP-Admin > Options > Reading. For me it’s 10 posts. Only exception I can think of, it’s possible to set the homepage to show ALL the posts, or all the posts from a particular range of time, then it would be a variable number.

    I know this didn’t answer your question, good luck with this! Why are you making a table? Is it something you can do with CSS instead?

    Thread Starter jojo0507

    (@jojo0507)

    Oh I see! The blog only has a 7-8 dummy posts while I am developing.

    I suppose this means that as soon as I get started, there will always be 10 posts, unless I change the source code or delete all posts?

    Maybe I can use CSS, but a table seemed easier.

    But you made me think though.
    Perhaps divs are a better way of achieving the effect I want. It might be! Thanks for the tip!

    But I would still need to dynamically set the number of divs, like I wanted to set the number of rows in the table.

    Does anybody know?

    Dgold

    (@dgold)

    well, you can kind of put the div’s in The Loop so it will repeat for each post

    also check out https://themes.wordpress.net/
    for ideas

    moshu

    (@moshu)

    But I would still need to dynamically set the number of divs, like I wanted to set the number of rows in the table.

    Does anybody know?

    That’s not how WP works. It would, probably, be beneficial to spend a bit of time studying The Loop mentioned above. To see it in action open for editing the index file of the default or classic theme. You have ONE Loop in all of them – but you can set your main page to show 1… 3… 17…etc. posts.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Which WP function?’ is closed to new replies.