0

I am use this way to get images in post like :

$images =& get_children( 'post_type=attachment&post_mime_type=image&post_parent='.get_the_ID() );

Its work good but show me this error in console : Only variables should be assigned by reference

How can solved it ?

Milap
  • 6,915
  • 8
  • 26
  • 46
  • Did you try : `$images = get_children( 'post_type=attachment&post_mime_type=image&post_parent='.get_the_ID() );` ? – Milap Jan 05 '16 at 06:39
  • You can pass by reference variables, new statements or references returned from functions. Read more [here](http://php.net/manual/en/language.references.pass.php). Just remove `&` and you'll get array in `$images` variable that you'll be able to use. – dingo_d Jan 05 '16 at 07:00
  • yes its work ,,, thankx – Almeeraj Tourism Jan 05 '16 at 07:13
  • https://stackoverflow.com/q/11777908/6521116 – LF00 May 24 '17 at 03:53

1 Answers1

0

The error is from the PHP configuration behind wordpress enforcing E_STRICT rules. You can only return variables by reference from a function - nothing else.

For more on how to alter your php.ini file (hides the warning but does not fix the cause) https://secure.php.net/manual/en/migrating5.errorrep.php

More here including examples of what (I think) you are doing here - https://secure.php.net/manual/en/language.references.return.php .

S.Pote
  • 71
  • 1
  • 5