I don't know much about php. I 'd like to ask a question about wordpress.

Source: Internet
Author: User
I don't know much about php. I 'd like to ask a question about wordpress.
This code reports an error

Error reported on the page:
Fatal error: Call to undefined function wp_list_cats () in D: \ phpnow \ htdocs \ mulan \ wp-content \ themes \ muse \ blog. php on line 48
The wp_list_pages () function is not defined.

You want to write templates using html css javascript.
When index. php is linked to blog. php, an error is reported when it is called in blog. php.
However, it would be normal to call index. php directly. index. php and blog. php are in the same directory. I don't understand why.


Reply to discussion (solution)

Index. php
Which function is introduced?
Blog. php does not

You can add some require in index. php to blog. php.

Index. php
Which function is introduced?
Blog. php does not

You can add some require in index. php to blog. php.

It seems that nothing has been introduced.
How does PHP introduce functions?
And where is the wp_list_cats function in wordpress?

In short, people have to observe the rules of their families.

In short, people have to observe the rules of their families.

But what should we do?

Solved
Add Or
The path is determined by myself, but I have a few questions.

1. what is the difference between require and require_once? the syntax for calling the function is the same. The difference is not seen on the page.
2. how to obtain the directory at the upper level in php? it is not ideal to use the absolute path ../It seems wrong.
3. after the wp_list_cats () function is called, the "page "?? How can I remove a link like "instance page "?
4. where is the source code of the wp_list_cats () function?

Require_once is a reference of php.

Like c's include

Http://www.csharpwin.com/dotnetspace/5716r9253.shtml lz can look at this require_once () function will first check whether the content of the target file has been imported before, if yes, it will not re-import the same content.

Hey... thank you ..
How does php obtain the Directory of the upper level, for example, in D:/phpnow/htdocs/mulan/wp-content/themes/my/index. php file represents D:/phpnow/htdocs/mulan/wp-blog-header.php file

../Write is acceptable, but this relative path is based on the relative path of the script you are running. If you confirm that the file to be referenced is in the directory at the previous level, it is likely that the page actually executed is not the one you expected.

For example:

Directory structure:
Test/1/a. php
Test/2/B. php
Test/2/c. php


A. php
-----------
Require '../2/c. php ';


B. php
-----------
Echo $;


C. php
-----------
$ A = 123;


Run http: // localhost/B. php

You may think it is true, because c. php is indeed a path like ../2/c. php compared with a. php. Unfortunately, if you actually execute B. php, the Directory of the current script is in the same directory as that of c. php. Therefore, c. php should be written:
./C. php or c. php

This is the disadvantage of relative paths. when Files reference each other, the relative paths will make the logic look messy. Therefore, we all like to use relative paths. But it is not good to write the physical path of the disk directly. when your project is migrated, the physical path may change.

The best way to write is based on the absolute path of the web root directory.
It starts with "/". This "/" is the root directory of your website, and then writes down the absolute path.
You can also use realpath and dirname to dynamically return the physical path and then create an absolute path.

The above sentence is incorrect:

Therefore, we all like to use absolute paths. Or use realpath, dirname, and so on to dynamically obtain the relative path.


What are the differences between require and require_once? you can search for the specific differences. I will not elaborate on them. But what you need to tell you is the best use of require and include in the actual project. do not use the one with once. the one with once only allows php to avoid repeated inclusion errors, however, this greatly reduces the efficiency. These problems can be avoided if the quality of programmers is high enough. it is not necessary to let php reduce its performance.

As for the issues 3 and 4, they all fall into the wordpress system itself. Strictly speaking, they do not fall into the php category. you can go to their official forum for help, which is much better than asking here.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.