1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Changing Archives

Discussion in 'WordPress' started by MakeThatDollar, Sep 4, 2008.

  1. #1
    Not sure how to do this so I thought I'd post it here.

    The following code:

    <?php get_archives('monthly', '', 'html', '', '', TRUE); ?>

    Is displaying archives like:

    September 2008 (1)

    How can I have it just show something like:

    September '08 (1)

    Thanks in advance..
     
    MakeThatDollar, Sep 4, 2008 IP
  2. keithjameslock

    keithjameslock Peon

    Messages:
    416
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    keithjameslock, Sep 4, 2008 IP
  3. MakeThatDollar

    MakeThatDollar Notable Member

    Messages:
    4,451
    Likes Received:
    158
    Best Answers:
    0
    Trophy Points:
    225
    #3
    So if I replace the old one with the new one, all would work fine?
     
    MakeThatDollar, Sep 5, 2008 IP
  4. godsofchaos

    godsofchaos Peon

    Messages:
    2,595
    Likes Received:
    124
    Best Answers:
    0
    Trophy Points:
    0
    #4
    They should, but still just in case... you should make a back up.
     
    godsofchaos, Sep 5, 2008 IP
  5. Dodger

    Dodger Peon

    Messages:
    1,494
    Likes Received:
    60
    Best Answers:
    0
    Trophy Points:
    0
    #5
    It should. The parameters seem to be identical. Plus when Wordpress finally removes the deprecated function from the core, your site will not be affected by it when you upgrade.

    As for your question, there is no way to accomplish this without editting that core function itself.

    You could however create your own function and put it into your theme's functions.php file.

    Copy the wp_get_archives function from the general-template.php core file in its entirety, paste into the theme function file, and give it a new name (ie my_get_archives).

    Find this code in the new function:

    $text = sprintf(__('%1$s %2$d'), wp_locale->get_month($arcresult->month), $arcresult->year);
    
    Code (markup):
    Replace it with this code (major changes hilited in red):

    $text = sprintf(__('%1$s [COLOR="Red"]&rsquo;%2$s[/COLOR]'), wp_locale->get_month($arcresult->month), [COLOR="Red"]substr(strval($arcresult->year),2)[/COLOR]);
    
    Code (markup):
    Don't forget to change your original template function call:

    <?php my_get_archives('monthly', '', 'html', '', '', TRUE); ?>
    Code (markup):
     
    Dodger, Sep 5, 2008 IP
    MakeThatDollar likes this.
  6. keithjameslock

    keithjameslock Peon

    Messages:
    416
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Yeah but if you start messing with core functions for something so trivial (sorry if I'm downplaying it) then it will be a pain when it comes time to upgrade Wordpress...I'd say leave it, and stop being such a perfectionist :) (I say that with luv)
     
    keithjameslock, Sep 5, 2008 IP
  7. MakeThatDollar

    MakeThatDollar Notable Member

    Messages:
    4,451
    Likes Received:
    158
    Best Answers:
    0
    Trophy Points:
    225
    #7
    @Dodger, sweet thanks. +rep to you.

    I made those changes and it shows it as:

    September ’08

    Which is right, but it's missing the (1) now... so it should be like this:

    September ’08 (1)

    Any ideas?
     
    MakeThatDollar, Sep 5, 2008 IP
  8. Dodger

    Dodger Peon

    Messages:
    1,494
    Likes Received:
    60
    Best Answers:
    0
    Trophy Points:
    0
    #8
    That code did not mess with the core function. It created a new function for the theme, which people do all the time for extra functionality.

    If he changes to another theme on down the line, then the function will have to be re-inserted into that themes functions.php file.

    I also know of people changing the core to remove Nofollow, rather than install another plugin. To each their own I guess. Some people just like to tinker with this stuff.

    @MakeThat Dollar: Did you change the code to false or leave it null?

    <?php my_get_archives('monthly', '', 'html', '', '', [B][COLOR="Red"]TRUE[/COLOR][/B]); ?>
    Code (markup):
     
    Dodger, Sep 5, 2008 IP
  9. keithjameslock

    keithjameslock Peon

    Messages:
    416
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Ah, OK, my bad. It just effects the theme and not the installation...I stand corrected. Good stuff.
     
    keithjameslock, Sep 5, 2008 IP
  10. MakeThatDollar

    MakeThatDollar Notable Member

    Messages:
    4,451
    Likes Received:
    158
    Best Answers:
    0
    Trophy Points:
    225
    #10
    I left it as TRUE.
     
    MakeThatDollar, Sep 6, 2008 IP