Frage

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.

War es hilfreich?

Lösung

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:

<?php 
define('WP_USE_THEMES', false);
require('./wp-load.php');
?>

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.

Andere Tipps

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit wordpress.stackexchange
scroll top