Support » Fixing WordPress » Loop filter by author passing php variable

  • Resolved Geoffrey Hale


    I’m writing a short loop for the sidebar of my author pages. From author.php I send:

    <?php $author = the_author_meta('ID'); ?>
    	<?php author_archive_titles($author); ?>

    And in functions.php I have:

    // Hale's Posts Archive List By Author
    	function author_archive_titles($authorID='', $qty='-1') {
    		echo $authorID;
    		query_posts(array('author' => $authorID, 'posts_per_page' => $qty, 'meta_key' => '_thumbnail_id' ));
    		if (have_posts()) :

    The echo $authorID responds well, displays the appropriate author ID, but the loop filter for author does not respond. If I replace $authorID with ‘4’ for example, it works! But even if echo $authorID produces 4, $authorID doesn’t work in the loop filter by author.

Viewing 1 replies (of 1 total)
  • Of course, I figured this out as soon as I finished posting it. Using get_the_author_meta instead works.

    <?php $author = get_the_author_meta('ID'); ?>

Viewing 1 replies (of 1 total)
  • The topic ‘Loop filter by author passing php variable’ is closed to new replies.