WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Problem with calling query_posts() (4 posts)

  1. ashvini_saxena
    Member
    Posted 3 years ago #

    Hey ,

    I am running XAMPP latest version and WP 3.0.
    Problem
    When I try to use query_posts() for retrieving posts by slugs.
    I am getting this error

    Warning: trim() expects parameter 1 to be string, array given in C:\xampp\htdocs\wordpress\wp-includes\query.php on line 1272

    for code
    <backticks>
    <?php

    get_header();
    query_posts(array('name'=>array('guitar','movie-post')));

    if (have_posts()) :
    while (have_posts()) :
    the_post();
    the_content();
    endwhile;
    endif;
    get_sidebar();
    get_footer();
    ?>
    I</backticks>

    What is wrong with this ? If I cannot use this , can you please suggest alternatives? This works when I put query as 'name=guitar'

  2. esmi
    Theme Diva & Forum Moderator
    Posted 3 years ago #

    There isn't a parameter called 'name':
    http://codex.wordpress.org/Function_Reference/query_posts

  3. alchymyth
    The Sweeper & Moderator
    Posted 3 years ago #

    'name' only allows one entry:
    http://codex.wordpress.org/Function_Reference/query_posts#Post_.26_Page_Parameters

    try and use the post ids instead with the post__in=array(3,7) parameter.

  4. ashvini_saxena
    Member
    Posted 3 years ago #

    Thanks to both of you for your reply. I guess , I will have to use your method Alchymyth.

Topic Closed

This topic has been closed to new replies.

About this Topic