I build a static page in my WordPress root folder. Now I'm trying to include a list of my categories with echo clpr_categories_list();.

Its not working because I some how have to tell the static page where to find my theme. How do I do this? Searched everywhere.


You need more than just telling the page where to find your theme. You will likely need to load WordPress.

You can do that with the following:

define('WP_USE_THEMES', false);

Is the clpr_categories_list() a theme function? You could just WP's wp_list_categories() function to what you need. The function accepts quite a number of arguments to customize the outpout.

  • Yes clpr_categories_list();is a theme function. Tried your solution but not getting any output. – joloshop Nov 26 '18 at 21:19
  • Got me into the right direction thanks, partly working now. – joloshop Nov 26 '18 at 22:33
  • Glad to hear things are moving in the right direction! – butlerblog Nov 26 '18 at 23:04

Instead of building a separate page, build a custom TEMPLATE page. Then it will be inside your theme and already have access to all the functions. You do this by copying the page.php file from your theme into a new file and putting the template name up at the top in comments like this:

/* Template Name: Category Page */

Now you can create a fresh page and set the template of that page to "Category Page," which will now appear in the drop down for template selection.

You can strip out and add whatever you want as far as code goes, to get rid of menus and other things you may not want.

  • Thanks, I knew this however I have a reason to build a static page instead. – joloshop Nov 26 '18 at 22:33
  • Then you need to use the wp-load idea from the first answer, but you must use require_once to include the functions file of your (child) theme. If you come to the page from "outside" the WordPress framework like that, then theme or custom functions must be explicitly included. And I run multisite so I'm constantly using switch_to_blog to get the correct parameters. If you're on single site, you may still need to use switch_to_blog to get $wpdb to act right, for instance. I am only guessing though. I do nothing custom with single site. – Elkrat Nov 27 '18 at 14:12

Not the answer you're looking for? Browse other questions tagged or ask your own question.