0

Im basically trying to show the archive for 1 week and instead of displaying the date, i want to display the day names. like monday-sunday. right now im using this code

wp_get_archives('type=daily&format=option&show_post_count=1&cat=13703&limit=')

which displays this

11/05/2015 (39)
11/04/2015 (39)
11/03/2015 19)
11/02/2015 (17)
11/01/2015 (6)
10/31/2015 (16)

but my goal would be to have it like this

Tuesday (39)
Wednesday(39)
Thursday 19)
Monday (17)
Sunday (6)
Saturday (16)

would appreciate any help

1 Answer 1

0

There are no arguments you can pass to do this, and no obvious filters. However, if you dig through the source you will see:

1426            if ( ! $archive_date_format_over_ride ) {
1427                    $archive_day_date_format = get_option( 'date_format' );
1428                    $archive_week_start_date_format = get_option( 'date_format' );
1429                    $archive_week_end_date_format = get_option( 'date_format' );
1430            }

That value is used here:

1514    $text = mysql2date( $archive_day_date_format, $date );

To create the "text" of the link.

It is possible to filter the output of get_option() :)

function hack_date_format_wpse_207803() {
  return 'l';
}
add_filter( 'pre_option_date_format','hack_date_format_wpse_207803' );
wp_get_archives('type=daily&show_post_count=1&cat=13703&limit=');
remove_filter( 'pre_option_date_format','hack_date_format_wpse_207803' );

Your format= argument is preventing links. I removed that.

4
  • thanks but it doesnt work throws a internal server error Commented Nov 6, 2015 at 15:51
  • @user3646085 : Sorry, there was an error when I pasted it over. It should work now... works like a charm when I test it.
    – s_ha_dum
    Commented Nov 6, 2015 at 15:54
  • seems to be working but it outputs at the top of the header? lie its brekaing the function file Commented Nov 6, 2015 at 16:02
  • It will output wherever you put the wp_get_archives() code. If you've put that in the header that is where it will output. If you put that whole block in the functions file then yes, the archives will output when the functions file loads. This is "proof of concept". You have to adapt to your case, but usage is pretty basic. 1) Put the function definition in your functions.php file. 2) Put the rest where you want the code to execute. Or 3) Put the whole thing where you want the code to execute.
    – s_ha_dum
    Commented Nov 6, 2015 at 16:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.