WordPress.org

Ready to get started?Download WordPress

Forums

search results variable (7 posts)

  1. amory
    Member
    Posted 9 years ago #

    is there a variable that can be called to display the number of results in a search?

  2. cynics
    Member
    Posted 9 years ago #

    just want to check whether anyone has any idea whether this can be done?

    ie. to show the number of results from search.

    thanks.

  3. amory
    Member
    Posted 9 years ago #

    I haven't found anything yet, however I stopped looking awhile ago.

  4. Dgold
    Member
    Posted 8 years ago #

    I'm wondering the same thing. Show the number of search results, just like it shows the number of posts by a category-name. How to do this?

  5. ifelse
    Member
    Posted 8 years ago #

    Edit: realised the code posted was incorrect.

  6. mat8iou
    Member
    Posted 8 years ago #

    This code (taken & modified out of a plugin) should do what you want.

    <?php
    preg_match('#FROM (.*) GROUP BY#', $request, $matches);
    $fromwhere = $matches[1];
    $numposts = $wpdb->get_var("SELECT COUNT(DISTINCT ID) FROM $fromwhere");
    if (0 < $numposts) $numposts = number_format($numposts);
    ?>
    <?php printf(__('Your search found %1$s matching posts'), $numposts, 'edit.php'); ?>

  7. nwfast
    Member
    Posted 8 years ago #

    The complete plugin may be viewed here:

    http://www.mtaylor.co.uk/wordpress/resultscount.phps

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags