• Hi,

    I need to create a function in functions.php that goes through all the posts in a specific category (to display their titles and some related pictures).

    I have created the first version of the function like this:

    function showPosts($category_name)
    {
    query_posts(‘category_name=$category_name&showposts=10’);

    while (have_posts()) : the_post();
    $title = get_the_title();
    endwhile;
    }

    Problem is that nothing is displayed. It looks like the query_posts call fails, but why is that? And what can I do about it?

    Thanks,
    Mads

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

The topic ‘How to call query_posts from functions.php?’ is closed to new replies.