Title: Permalink hack
Last modified: August 19, 2016

---

# Permalink hack

 *  [Sergio De Falco](https://wordpress.org/support/users/sgr33n/)
 * (@sgr33n)
 * [18 years, 3 months ago](https://wordpress.org/support/topic/permalink-hack/)
 * I’ve to do a new get_archives() function like in order to filter the author’s
   posts.
 * Everything went ok selecting the posts, but not getting the right link using 
   permalinks.
 * The problem, in my opinion is here:
 * >  function sgr_get_month_link($year, $month, $author_id, $author_nicename) {
   > 
   > global $wp_rewrite; if ( !$year ) $year = gmdate(‘Y’, time()+(get_option(‘gmt_offset’)*
   > 3600)); if ( !$month ) $month = gmdate(‘m’, time()+(get_option(‘gmt_offset’)*
   > 3600)); $monthlink = $wp_rewrite->get_month_permastruct(); if ( !empty($monthlink)){
   > $monthlink = str_replace(‘%author%’, $author_nicename, $monthlink); $monthlink
   > = str_replace(‘%year%’, $year, $monthlink); $monthlink = str_replace(‘%monthnum%’,
   > zeroise(intval($month), 2), $monthlink); return apply_filters(‘month_link’,
   > get_option(‘home’) . user_trailingslashit($monthlink, ‘month’), $year, $month);}
   > else { return apply_filters(‘month_link’, get_option(‘home’) . ‘/?author=’ .
   > $author_id . ‘&m=’ . $year . zeroise($month, 2), $year, $month); } }
 * As you can see I added the author_id variable to the non-permalink option, but
   I really cannot understand how to modify the permalink option in order to have
   the author too, because the get_month_permastruct is related just to month.
 * Can somebody help me?

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

 *  Thread Starter [Sergio De Falco](https://wordpress.org/support/users/sgr33n/)
 * (@sgr33n)
 * [18 years, 3 months ago](https://wordpress.org/support/topic/permalink-hack/#post-701972)
 * Perhaps solved. Now it’s ok, but it puts two slashes after the author name:
 * >  function sgr_get_month_link($year, $month, $author_id, $author_nicename) {
   > 
   > global $wp_rewrite; if ( !$year ) $year = gmdate(‘Y’, time()+(get_option(‘gmt_offset’)*
   > 3600)); if ( !$month ) $month = gmdate(‘m’, time()+(get_option(‘gmt_offset’)*
   > 3600)); $monthlink = $wp_rewrite->get_month_permastruct(); if ( !empty($monthlink)){
   > $monthlink = str_replace(‘%year%’, $year, $monthlink); $monthlink = str_replace(‘%
   > monthnum%’, zeroise(intval($month), 2), $monthlink); $author_home = get_author_link(
   > false, $author_id, $author_nicename); return apply_filters(‘month_link’, $author_home.
   > user_trailingslashit($monthlink, ‘month’), $year, $month); } else { return 
   > apply_filters(‘month_link’, get_option(‘home’) . ‘/?author=’ . $author_id .‘&
   > m=’ . $year . zeroise($month, 2), $year, $month); } }
 *  Thread Starter [Sergio De Falco](https://wordpress.org/support/users/sgr33n/)
 * (@sgr33n)
 * [18 years, 3 months ago](https://wordpress.org/support/topic/permalink-hack/#post-701974)
 * Solved with substr. Do you think is ok ?
 * >  function sgr_get_month_link($year, $month, $author_id, $author_nicename) {
   > 
   > global $wp_rewrite;
   >  if ( !$year )
   >  $year = gmdate(‘Y’, time()+(get_option(‘gmt_offset’) * 3600));
   > if ( !$month ) $month = gmdate(‘m’, time()+(get_option(‘gmt_offset’) * 3600));
   > $monthlink = $wp_rewrite->get_month_permastruct(); if ( !empty($monthlink) ){
   > $monthlink = str_replace(‘%year%’, $year, $monthlink); $monthlink = str_replace(‘%
   > monthnum%’, zeroise(intval($month), 2), $monthlink); $author_home = get_author_link(
   > false, $author_id, $author_nicename); $author_home = substr($author_home, 0,-
   > 1); return apply_filters(‘month_link’, $author_home . user_trailingslashit(
   > $monthlink, ‘month’), $author, $year, $month); } else { return apply_filters(‘
   > month_link’, get_option(‘home’) . ‘/?author=’ . $author_id . ‘&m=’ . $year .
   > zeroise($month, 2), $author, $year, $month); } }

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

The topic ‘Permalink hack’ is closed to new replies.

## Tags

 * [author](https://wordpress.org/support/topic-tag/author/)
 * [permalink](https://wordpress.org/support/topic-tag/permalink/)

 * 2 replies
 * 1 participant
 * Last reply from: [Sergio De Falco](https://wordpress.org/support/users/sgr33n/)
 * Last activity: [18 years, 3 months ago](https://wordpress.org/support/topic/permalink-hack/#post-701974)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
