$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>Static Page with php echo|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

Static Page with php echo

matteradmin7PV0评论
This question already has answers here: What is the correct way to use WordPress functions outside WordPress files? (7 answers) Closed 6 years ago.

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.

This question already has answers here: What is the correct way to use WordPress functions outside WordPress files? (7 answers) Closed 6 years ago.

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.

Share Improve this question edited Nov 26, 2018 at 21:10 Krzysiek Dróżdż 25.6k9 gold badges53 silver badges74 bronze badges asked Nov 26, 2018 at 20:59 joloshopjoloshop 211 silver badge8 bronze badges 0
Add a comment  | 

2 Answers 2

Reset to default 0

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.

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.

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far