Title: problem with get_author_posts_url
Last modified: May 1, 2018

---

# problem with get_author_posts_url

 *  Resolved [Auror](https://wordpress.org/support/users/auror/)
 * (@auror)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/problem-with-get_author_posts_url/)
 * Hi! I’m running into this problem with a custom page I’ve set up to list authors
   according to a custom field (using Advanced Custom Fields).
    Even though the 
   query works fine (that is, the results are those I’m expecting), I simply can’t
   get the URL for the author archive page to work. Here’s my code:
 *     ```
       <?php
   
       /**
       * Template Name: Authors list
       * @package Educaz
       */
   
        get_header(); ?>
   
       <div id="primary" class="content-area grid__col grid__col--2-of-3">
       	<main id="main" class="site-main" role="main">
   
           <?php
   
           // wp_user_query arguments
           $argsProf =array(
             'order'      => 'ASC',
             'orderby'    => 'ID',
             'meta_key'   => 'academic_level',
             'meta_value' => 'professor'
           );
   
           //create wp_user_query object
           $queryProf = new wp_user_query($argsProf);
           //get the results
           $professors = $queryProf->get_results();
   
           //check for professors
           if (! empty($professors)) {
             echo '<ul>';
             foreach ($professors as $professor) {
               $professor_info = get_userdata($professor->ID);
               echo '<li><a href="'  .  <strong>esc_url(get_author_posts_url($professor_info->ID, $professor_info->user_nicename))</strong> . '">' . $professor_info->display_name . '</a></li>';
             }
             echo '</ul>';
           }
           ?>
   
       		</main><!-- #main -->
       	</div><!-- #primary -->
   
       <?php
       get_sidebar();
       get_footer();
       ```
   
 * The code works fine if don’t call _get\_header_, but then, of course, the theme
   doesn’t load properly on the page.
    Two things I’ve tried also didn’t work: 1.
   Someone suggested I shouldn’t do a _wp\_user\_query_ using custom fields as _meta\
   _key_. I then changed the query to a simpler one, using ‘search’ as a parameter.
   No luck. (Again, the query in the code above seems to work fine, since it retrieves
   the results I’m expecting) 2. I’ve also tried hardcoding an ID in _get\_author\
   _posts\_url_. That also doesn’t work, surprisingly. I’ve even tried echoing the
   _get\_author\_posts\_url_, but I get nothing.

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

 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/problem-with-get_author_posts_url/#post-10236467)
 * When you call get_header(), it fires the wp_head action which all sorts of plugins
   and themes use to initialize something they need for the output. One of those
   modules is creating some sort of conflict with get_author_posts_url(), as it 
   should always work when fed a proper ID.
 * You can try deactivating various modules to discover which is causing a conflict
   with get_author_posts_url(), or work around it by building the URL yourself based
   on $professor_info->user_nicename. The correct URL depends on your site settings,
   but it’s often `site_url("/author/{$professor_info->user_nicename}/")`
 *  Thread Starter [Auror](https://wordpress.org/support/users/auror/)
 * (@auror)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/problem-with-get_author_posts_url/#post-10236735)
 * Wow, you were completely right. It worked. I deactivated all plugins, and it 
   worked. I then re-activated three or four at a time to narrow down the culprit.
   It was a plugin called Show Hide Author. I’ll try and contact the author of that
   plugin. Many thanks!
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/problem-with-get_author_posts_url/#post-10237345)
 * You’re welcome. I guess that plugin was doing its job a little too well on the
   hiding end 🙂

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

The topic ‘problem with get_author_posts_url’ is closed to new replies.

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 3 replies
 * 2 participants
 * Last reply from: [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * Last activity: [8 years, 1 month ago](https://wordpress.org/support/topic/problem-with-get_author_posts_url/#post-10237345)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
