WordPress.org

Ready to get started?Download WordPress

Forums

Archive page header plugin (8 posts)

  1. mat8iou
    Member
    Posted 8 years ago #

    I've just finished creating my first plugin for WordPress.

    The purpose of the plugin is to create a header line when you are viewing search results (or date archives or category archives), that will tell you how many results there were & where you are in the results.
    eg.
    Showing results 1 - 10 of 45 for the search terms search terms.

    You can download the code here:
    http://www.mtaylor.co.uk/wordpress/resultscount.phps

    To use it, all you need to do is install it in the plugins folder & then add:
    <?php wp_searchheader()?>

    to the page template wherever you want the search header to appear.

    You can see it in action on any of the archive pages of my site at http://www.elginism.com

    Let me know if you have any suggestions on how it can be improved, or any comments on it.

  2. Dgold
    Member
    Posted 8 years ago #

    This plugin is cool. I could see this being a regular part of WordPress Search for me.

    Only problem I had, my Search Template currently calls ALL search results by using (-1) which someone on this forum told me about. Could you make the plugin so it says "Showing ALL" instead of "Showing 1 to -1"? On second thought, EDIT: I customized your plugin in my version to say "We found 46 or more results for the search terms: panic." instead of giving a range at all. I like this better for me. This also works when there's 1 result ("1 or more results"). But the original way you did it is more conventional.

    Example on my site:
    http://dgold.info/radio/search/panic

    thanks for the plugin

  3. Dgold
    Member
    Posted 8 years ago #

    OK, uh-oh.

    I installed it on 3 blogs, and it doesn't work on one of them. Well, the plugin works fine, but there's an error message at the top of my Admin pages that says:

    Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/green/wp-content/plugins/resultscount.php:63) in /var/www/html/green/wp-admin/admin.php on line 10, 11, 12, 13

    What's wrong here?

  4. mat8iou
    Member
    Posted 8 years ago #

    I never knew you could do that to make them all display like that.

    I've updated it, at the same location as before, to detect whether the -1 value is being used.

    Glad you think it is useful.

  5. mat8iou
    Member
    Posted 8 years ago #

    Doesn't do it for me.

    The problem that you describe (which I have seen before) is this one:
    http://wordpress.org/support/topic/30278

    Caused by white space at the start or end of a php file.

  6. Dgold
    Member
    Posted 8 years ago #

    Thanks mat8, and sorry to hijack your Announce thread with my questions.
    EDIT: Fixed. You're right there was a white space at the end of my resultscount.php

  7. Dgold
    Member
    Posted 8 years ago #

    Attention: mat8iou

    EDIT: I have now learned that I should look for a blank space at the end of the PHP for this plugin.

    It mentions a problem with UTF-8. Could this be affected by this plugin?

    EDIT2: I found the blank space at the end of the file. Deleted that space, it fixed it. Thanks

  8. nwfast
    Member
    Posted 8 years ago #

    Awesome!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags