Warning: urlencode() expects parameter 1 to be string, array given in D:\xamppp\htdocs\sample\wp-includes\formatting.php on line 3690

When I try to give the category_name in the query_post,

<?php
   $args=query_posts(
    array(
     'posts_per_page' => -1,
   'category_name' =>array('Breaking News Stories', 'Call-out', 'Featured Story', 'Standard Stories')
  ));
 ?>

I’m having the above warning in formatting.php file.
line 3690 has the below code:

<?php
   function wp_basename( $path, $suffix = '' )
     {
      return urldecode( basename( str_replace( array( '%2F', '%5C' ), "https://wordpress.stackexchange.com/", urlencode( $path ) ), $suffix ) );
     }
?>

3 Answers
3

First of all, never use query_posts. Rather use WP_Query to construct your custom query which is the prefered way

You are also using the category_name parameter wrong. If you look at the WP_Query documentation, it states

category_name (string) – use category slug (NOT name).

Go and have a look at the examples given in the docomentation under the category parameters

EDIT

You need to do someting like this

'category_name' => 'SLUG OF Breaking News Stories, SLUG OF Call-out, SLUG OF Featured Story, SLUG OF Standard Stories'

Leave a Reply

Your email address will not be published. Required fields are marked *