• Anonymous User 17976131

    (@anonymized-17976131)


    I’d like WordPress to add some additional variables for permalinks, such that we can have, for example

    January or Jan or january or jan

    instead of having a two-digit month number.

    I’ve found it’s easy to make a custom function that allows a custom variable in the permalinks setting but WordPress only understands it for the purposes of post permalinks. Date-based archives still only function under the default two-digit month number.

    Years and years ago, I used this permalink format under, I think, Moveable Type, where it was a built-in option, and am using it again on my current blog (via a custom variable, per above) but would like my date-based archives to also use the same format.

    Thanks.

    • This topic was modified 1 year, 2 months ago by Anonymous User 17976131.
Viewing 5 replies - 1 through 5 (of 5 total)
  • You can also define your own placeholders aka tags for this. There is a short guide here: https://wordpress.stackexchange.com/questions/301167/add-or-create-custom-structure-tags-to-permalink

    If you have specific requests for additions that should be included in the core itself, please feel free to report this to the developers here: https://core.trac.www.ads-software.com/

    Thread Starter Anonymous User 17976131

    (@anonymized-17976131)

    As noted, I have such a tag. It doesn’t effect the date archive URLs, only the post URLs.

    (Why is this forum indicated for feature requests if I just have to go post somewhere else with a feature request?)

    What does the code you use for this look like? And where did you put it in your project?

    Thread Starter Anonymous User 17976131

    (@anonymized-17976131)

    I use a plugin called Custom Snippets so I don’t have to mess with editing functions.php. The snippet in question is much like the example you linked.

    function custom_monthname_rewrite_tag() {
    add_rewrite_tag('%monthname%', '([a-zA-Z]{3})');
    }
    add_action('init', 'custom_monthname_rewrite_tag');
    function custom_monthname_permalink($permalink, $post, $leavename) {
    if (false !== strpos($permalink, '%monthname%')) {
    $monthname = date('M', strtotime($post->post_date));
    $permalink = str_replace('%monthname%', $monthname, $permalink);
    }
    return $permalink;
    }
    add_filter('post_link', 'custom_monthname_permalink', 10, 3);

    As noted, this is fine for posts, but it’s not like WordPress has any idea of using the same format for the date-based archives.

    Thread Starter Anonymous User 17976131

    (@anonymized-17976131)

    Really, this could be broadened to a more general “wider array of options for permalinks”, I guess.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Feature request: %monthname% / %monthnam% (or whatnot) variables for permalinks’ is closed to new replies.