This question already has answers here: What is the correct way to use WordPress functions outside WordPress files? (7 answers) Closed 6 years ago.admin管理员组文章数量:1130349
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 02 Answers
Reset to default 0You 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.
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 02 Answers
Reset to default 0You 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.
本文标签: Static Page with php echo
版权声明:本文标题:Static Page with php echo 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749150575a2323745.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论