WordPress archive title display switch

While creating my Blankwork I was looking for different examples of archives pages, since I never used them much. In the end, I was pretty disapointed with all of them.

For example, an else if statement list with opening PHP tags every time, repeating same text and adding comments in between. In my code editor it looked like one big rainbow. An example (which is short and a bit more readable):

I like when everything is clear and easy readable even in code. of course you can dig-through anything, but I made this little snippet just for those, who want a little more clean archives code.

So, I made my own little snippet, which is a bit more Designer friendly, here you go:

  • Great little snippet!

    I’ve implemented this on my wordpress site to great success except for one thing… for some reason appending anything before a reference function isn’t putting it before it, but after. So for example:

    The part-
    elseif (is_author()):
    $return = “Author: “.get_the_author();

    returns this:
    AuthorNameAuthor:

    And likewise, I tried to add “Archive for ” before the various dates statements (day, month, year). and it came out like:

    June, 2012Archive for

    I don’t really understand why they are showing up after the functions. Any ideas? Heres the full script I’m using:

  • When I wrote this up, I didn’t pay attention to “the” keyword. Instead of “the_time()” it should actually be “get_the_time()”. The first way instantly calls the echo function.

Leave a Reply

Your email address will not be published. Required fields are marked *