WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Count all posts made (5 posts)

  1. maerk
    Member
    Posted 8 years ago #

    Is there a simple way of getting the number of posts in the database?

    At the moment I'm trying to use:

    $count = $wpdb->get_results('SELECT COUNT(*) FROM wp_posts');

    This isn't working, because $count stays empty.

    It must return a number, because I'm using this later on:

    $remainder = $count - 10;

  2. Mark (podz)
    Support Maven
    Posted 8 years ago #

    http://www.lesterchan.net/portfolio/programming.php
    The WP-stats plugin there has the right code (and a whole heap more). Might be of use?

  3. maerk
    Member
    Posted 8 years ago #

    Thank you, that's perfect :D The code in question (for future folks) is:

    $count = $wpdb->get_var("SELECT COUNT(ID) FROM $wpdb->posts");

  4. DesignPastor
    Member
    Posted 8 years ago #

    nice site maerk ...

    what did you use to do the photo gallery.

    i like that ..

    DesignPastor

  5. maerk
    Member
    Posted 8 years ago #

    Thank you! I use eSPG (enhanced Simple PHP Gallery)

    http://www.quirm.net/category.php?id=14

    It's currently a bit broken since I completely destroyed it a while ago by overwriting the directory. What you see there is a temporary fix :( I'm planning a redesign shortly, so it seems pointless to do anything too drastic to it just yet, but at least it works.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.