Support » Themes and Templates » [Resolved] WP_Query inside functions.php

[Resolved] WP_Query inside functions.php

  • Hello,

    there is a custom WP theme. The directory with the theme also contains function.php file where are stored frequently used theme shortcuts. index.php of this theme shows the recent posts via the global loop. Also I want to show on index.php links to some static pages which meet some condition.

    To do that I create a function in functions.php like this:

    function print_custom_pages($tp)
      $query = new WP_Query("post_type=page&meta_key=pg_type&meta_value=$tp");
      while ($query->have_posts()) {
         /* echo "POST found<br />\n"; */  // is not printed
         the_permalink(); // print a permalink of the page

    but it does not work: no posts are found via WP_Query. What I am doing wrong?


Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Resolved] WP_Query inside functions.php’ is closed to new replies.