Title: Question re: the API
Last modified: August 18, 2016

---

# Question re: the API

 *  [greghaspants](https://wordpress.org/support/users/greghaspants/)
 * (@greghaspants)
 * [21 years, 11 months ago](https://wordpress.org/support/topic/question-re-the-api/)
 * Tonight, I sat down with the impression that I could write a quick and dirty 
   WP plugin. Not that I’ve ever done this before, mind you, but the goal of the
   plugin seemed so simple that I’m surprised that it hasn’t been done before. In
   fact, I’m sure it has.
    The idea was to make a plugin that would print different
   error messages based on what was requested of the database. For every different
   case, as of the default installation, you get the message “Sorry, but not posts
   matched your criteria” (or what have you). When I designed my site, I was able
   to make different messages for the following cases:
    - When a yearly archive is requested, and there is no post for that year.
    - When a monthly archive is requested, and there is no post for that month.
    - When a daily archive is requested, and there is no post for that day.
    - When a category archive is requested, and there is no post associated with
      that category.
    - When the weblog is searched, but there are no posts that contain that search
      query.
    - When a post is requested, but that post does not exist.
 * Which, given the perfectionist I can be, shouldn’t be surprising to anybody.
   
   However, when I got down to actually writing the thing, I encountered some problems.
   I got it to more or less work when viewing weblog pages, but the administrative
   pages were completely unaccessible. Error messages to the effect of “header already
   sent.” Perhaps it has something to do with the API, and that there aren’t any
   filter or action hooks specifically associated with the error message. So I don’t
   really know. Like I said, I’ve never played with the API before, so I’m almost
   positive it’s related to that. Any comments? Source code will be posted shortly.
   Thanks for any help, in advance.

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Thread Starter [greghaspants](https://wordpress.org/support/users/greghaspants/)
 * (@greghaspants)
 * [21 years, 11 months ago](https://wordpress.org/support/topic/question-re-the-api/#post-66806)
 * “Source code will be posted shortly.”
    Here you go: [http://stuffandthings.org/pretend/stuff.txt](http://stuffandthings.org/pretend/stuff.txt)
   Two ammendments to my post, if I may.
    1. The code as posted did not actually work when looking at the actual blog pages.
       Originally, instead of assigning different items to `$to_return`, I had a bunch
       of print statements. I lost that version. But, both versions cause the same 
       problem anyway.
    2. I apologize for the loose formatting. I’m normally really _really_ strict about
       that, but I’m just not feeling that tonight. It’s unprofessional, I am aware.
 * Again, thanks in advance.
 *  [Root](https://wordpress.org/support/users/root/)
 * (@root)
 * [21 years, 11 months ago](https://wordpress.org/support/topic/question-re-the-api/#post-66832)
 * If there has been a daily post it will show in the calendar. If there is no post
   in the category the category wont show at all.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Question re: the API’ is closed to new replies.

 * 2 replies
 * 2 participants
 * Last reply from: [Root](https://wordpress.org/support/users/root/)
 * Last activity: [21 years, 11 months ago](https://wordpress.org/support/topic/question-re-the-api/#post-66832)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
