I have created in my theme folder a PHP file named gallery.php. In this file I want to use WP_Query function, but I can’t do this because it shows error.
Is possible to do this?
Thanks in advance!
I have created in my theme folder a PHP file named gallery.php. In this file I want to use WP_Query function, but I can’t do this because it shows error.
Is possible to do this?
Thanks in advance!
Comments are closed.
You must put your
gallery.php
in the same theme folder, where the theme’sfunctions.php
resides. Then add a single line infunctions.php
:It’ll include the
gallery.php
file intofunctions.php
andgallery.php
will behave likefunctions.php
.So, you have to keep in mind that,
functions.php
file is a file for WordPress and PHP functions. So anything out-of-format without proper formatting may occur error into the whole site – andfunctions.php
is a core file of any theme.I don’t think it’s impossible using
WP_Query()
inside afunctions.php
– but you have to format and place it properly.