WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Loop filter by author passing php variable (2 posts)

  1. Geoffrey Hale
    Member
    Posted 2 years ago #

    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.

  2. Geoffrey Hale
    Member
    Posted 2 years ago #

    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'); ?>

Topic Closed

This topic has been closed to new replies.

About this Topic