Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>basically, all you need to do is set $curauth</p> <pre><code>&lt;?php $curauth = (isset($_GET['author_name'])) ? get_user_by('slug', $author_name) : get_userdata(intval($author)); ?&gt; </code></pre> <p>example for an author page: <a href="http://codex.wordpress.org/Author_Templates" rel="nofollow">http://codex.wordpress.org/Author_Templates</a></p> <pre><code>&lt;?php get_header(); ?&gt; &lt;div id="content" class="narrowcolumn"&gt; &lt;!-- This sets the $curauth variable --&gt; &lt;?php $curauth = (isset($_GET['author_name'])) ? get_user_by('slug', $author_name) : get_userdata(intval($author)); ?&gt; &lt;h2&gt;About: &lt;?php echo $curauth-&gt;nickname; ?&gt;&lt;/h2&gt; &lt;dl&gt; &lt;dt&gt;Website&lt;/dt&gt; &lt;dd&gt;&lt;a href="&lt;?php echo $curauth-&gt;user_url; ?&gt;"&gt;&lt;?php echo $curauth-&gt;user_url; ?&gt;&lt;/a&gt;&lt;/dd&gt; &lt;dt&gt;Profile&lt;/dt&gt; &lt;dd&gt;&lt;?php echo $curauth-&gt;user_description; ?&gt;&lt;/dd&gt; &lt;/dl&gt; &lt;h2&gt;Posts by &lt;?php echo $curauth-&gt;nickname; ?&gt;:&lt;/h2&gt; &lt;ul&gt; &lt;!-- The Loop --&gt; &lt;?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?&gt; &lt;li&gt; &lt;a href="&lt;?php the_permalink() ?&gt;" rel="bookmark" title="Permanent Link: &lt;?php the_title(); ?&gt;"&gt; &lt;?php the_title(); ?&gt;&lt;/a&gt;, &lt;?php the_time('d M Y'); ?&gt; in &lt;?php the_category('&amp;');?&gt; &lt;/li&gt; &lt;?php endwhile; else: ?&gt; &lt;p&gt;&lt;?php _e('No posts by this author.'); ?&gt;&lt;/p&gt; &lt;?php endif; ?&gt; &lt;!-- End Loop --&gt; &lt;/ul&gt; &lt;/div&gt; &lt;?php get_sidebar(); ?&gt; &lt;?php get_footer(); ?&gt; </code></pre> <hr> <p><strong>Edit</strong></p> <p>I will explain what <code>$curauth = (isset($_GET['author_name'])) ? get_user_by('slug', $author_name) : get_userdata(intval($author));</code> does</p> <p><code>isset($_GET['author_name']) ?</code> checks whether a parameter with the username is present in the URL, like: www.myexamplewebsite.com/author/danieltulp <a href="http://davidwalsh.name/php-ternary-examples" rel="nofollow">it is a shorthand if/else statement</a> </p> <p>if URL has an username the code will try to get it with <code>get_user_by('slug', $author_name)</code></p> <p>if it doesn't it will try to get it with the <a href="http://codex.wordpress.org/Function_Reference/get_userdata" rel="nofollow">get_userdata Wordpress</a> function with <code>get_userdata(intval($author))</code></p> <p>of course, you are not refering to the user in the URL, so you just need to set the currentauth like:</p> <pre><code>$curauth = (is_home()) ? "liamhodnett" : (isset($_GET['author_name'])) ? get_user_by('slug', $author_name) : get_userdata(intval($author)); </code></pre> <hr> <p><strong>Edit 2</strong> If all else fails (haven't tested the code above, so could very well be possible), make your own database call with <a href="http://codex.wordpress.org/Template_Tags/get_posts" rel="nofollow">get_posts()</a>:</p> <pre><code>$args = array( 'author' =&gt; 1 // this should be your user ID, or use 'author_name' =&gt; 'liamhodnett' ); // get my posts 'ASC' $myposts = get_posts( $args ); </code></pre> <p>Then use the $mypost array for your loop:</p> <pre><code>foreach ( $myposts as $post ) : setup_postdata( $post ); ?&gt; &lt;h2&gt;&lt;a href="&lt;?php the_permalink(); ?&gt;"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/h2&gt; &lt;?php the_content(); ?&gt; &lt;?php endforeach; wp_reset_postdata();?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload