Home CMS Tutorial WordPress What are the commonly used functions in wordpress templates?

What are the commonly used functions in wordpress templates?

Nov 18, 2019 pm 03:20 PM
wordpress Commonly used functions template

What are the commonly used functions in wordpress templates?

What are the commonly used functions in wordpress templates

If you are a newbie in wordpress, then these functions are useful to you It is said to be very useful. For example, if you like a certain theme but need to change it to suit your requirements, then you must know these functions and names

1. Basic template file

1

2

3

4

5

6

7

8

9

10

11

12

style.css : CSS(样式表)文件

index.php : 主页模板

archive.php : Archive/Category模板

404.php : Not Found 错误页模板

comments.php : 留言/回复模板

footer.php : Footer模板

header.php : Header模板

sidebar.php : 侧栏模板

page.php : 内容页(Page)模板

single.php : 内容页(Post)模板

searchform.php : 搜索表单模板

search.php : 搜索结果模板

Copy after login

2. Basic condition judgment Tag

1

2

3

4

5

6

7

8

9

10

11

12

13

14

is_home() : 是否为主页

is_single() : 是否为内容页

(Post) is_page() : 是否为内容页

(Page) is_category() : 是否为Category/Archive页

is_tag() : 是否为Tag存档页

is_date() : 是否为指定日期存档页

is_year() : 是否为指定年份存档页

is_month() : 是否为指定月份存档页

is_day() : 是否为指定日存档页

is_time() : 是否为指定时间存档页

is_archive() : 是否为存档页

is_search() : 是否为搜索结果页

is_404() : 是否为 “HTTP 404: Not Found” 错误页

is_paged() : 主页/Category/Archive页是否以多页显示

Copy after login

3. Header part PHP function

1

2

3

4

5

6

7

8

9

10

11

12

<!–p bloginfo(’name’);–>: 博客名称(Title)

<!–p bloginfo(’stylesheet_url’);–>: CSS文件路径

<!–p bloginfo(’pingback_url’);–>: PingBack Url

<!–p bloginfo(’template_url’);–>: 模板文件路径

<!–p bloginfo(’version’);–>: WordPress版本

<!–p bloginfo(’atom_url’);–>: Atom Url

<!–p bloginfo(’rss2_url’);–>: RSS 2.o Url

<!–p bloginfo(’url’);–>: 博客 Url

<!–p bloginfo(’html_type’);–>: 博客网页Html类型

<!–p bloginfo(’charset’);–>: 博客网页编码

<!–p bloginfo(’description’);–>: 博客描述

<!–p wp_title();–>: 特定内容页(Post/Page)的标题

Copy after login

4. Template PHP functions and commands

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

<!–p get_header();–>: 调用Header模板

<!–p get_sidebar();–>: 调用Sidebar模板

<!–p get_footer();–>: 调用Footer模板

<!–p the_content();–>: 显示内容(Post/Page)

<!–p if(have_posts()) :–>: 检查是否存在Post/Page

<!–p while(have_posts()) : the_post();–>: 如果存在Post/Page则予以显示

<!–p endwhile;–>: While 结束

<!–p endif;–>: If 结束

<!–p the_time(’字符串’)–>: 显示时间,时间格式由“字符串”参数决定,具体参考PHP手册

<!–p comments_popup_link();–>: 正文中的留言链接。如果使用 comments_popup_script() ,则留言会在新窗口中打开,反之,则在当前窗口打开

<!–p the_title();–>: 内容页(Post/Page)标题

<!–p the_permalink()–>: 内容页(Post/Page) Url

<!–p the_category(’,’)–>: 特定内容页(Post/Page)所属Category

<!–p the_author();–>: 作者

<!–p the_ID();–>: 特定内容页(Post/Page) ID

<!–p edit_post_link();–>: 如果用户已登录并具有权限,显示编辑链接

<!–p get_links_list();–>: 显示Blogroll中的链接

<!–p comments_template();–>: 调用留言/回复模板

<!–p wp_list_pages();–>: 显示Page列表

<!–p wp_list_categories();–>: 显示Categories列表

<!–p next_post_link(’%link’);–>: 下一篇文章链接

<!–p previous_post_link(’%link’);–>: 上一篇文章链接

<!–p get_calendar();–>: 日历

<!–p wp_get_archives()–>: 显示内容存档

<!–p posts_nav_link();–>: 导航,显示上一篇/下一篇文章链接

<!–p include(TEMPLATEPATH . ‘/文件名’);–>: 嵌入其他文件,可为定制的模板或其他类型文件

Copy after login

5. Other template-related functions

1

2

3

4

5

6

7

<!–p _e(’Message’);–>: 输出相应信息

<!–p wp_register();–>: 显示注册链接

<!–p wp_loginout();–>: 显示登录/注销链接

<!–ext pag–>: 将当前内容分页

<!–or–>: 将当前内容截断,以不在主页/目录页显示全部内容

<!–p timer_stop(1);–>: 网页加载时间(秒)

<!–p echo get_num_queries();–>: 网页加载查询量

Copy after login

Of course, WordPress has far more functions than these. If you have higher For requirements, please visit WordPress official code page.

Recommended tutorial: WordPress tutorial

The above is the detailed content of What are the commonly used functions in wordpress templates?. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP vs. Flutter: The best choice for mobile development PHP vs. Flutter: The best choice for mobile development May 06, 2024 pm 10:45 PM

PHP and Flutter are popular technologies for mobile development. Flutter excels in cross-platform capabilities, performance and user interface, and is suitable for applications that require high performance, cross-platform and customized UI. PHP is suitable for server-side applications with lower performance and not cross-platform.

In which folder are wordpress articles located? In which folder are wordpress articles located? Apr 16, 2024 am 10:29 AM

WordPress posts are stored in the /wp-content/uploads folder. This folder uses subfolders to categorize different types of uploads, including articles organized by year, month, and article ID. Article files are stored in plain text format (.txt), and the filename usually includes its ID and title.

Where is the wordpress template file? Where is the wordpress template file? Apr 16, 2024 am 11:00 AM

WordPress template files are located in the /wp-content/themes/[theme name]/ directory. They are used to determine the appearance and functionality of the website, including header (header.php), footer (footer.php), main template (index.php), single article (single.php), page (page.php), Archive (archive.php), category (category.php), tag (tag.php), search (search.php) and 404 error page (404.php). By editing and modifying these files, you can customize the appearance of your WordPress website

Which version of wordpress is stable? Which version of wordpress is stable? Apr 16, 2024 am 10:54 AM

The most stable WordPress version is the latest version because it contains the latest security patches, performance enhancements, and introduces new features and improvements. In order to update to the latest version, log into your WordPress dashboard, go to the Updates page and click Update Now.

Does wordpress need to be registered? Does wordpress need to be registered? Apr 16, 2024 pm 12:07 PM

WordPress requires registration. According to my country's "Internet Security Management Measures", websites that provide Internet information services within the country must register with the local provincial Internet Information Office, including WordPress. The registration process includes steps such as selecting a service provider, preparing information, submitting an application, reviewing and publishing, and obtaining a registration number. The benefits of filing include legal compliance, improving credibility, meeting access requirements, ensuring normal access, etc. The filing information must be true and valid, and must be updated regularly after filing.

What is the wordpress article database? What is the wordpress article database? Apr 16, 2024 am 11:12 AM

WordPress uses MySQL as its article database, its main functions include: storing articles, comments, users and website configuration data. The data tables include: wp_posts (articles), wp_postmeta (metadata), wp_comments (comments), wp_commentmeta (comment metadata), wp_users (users). The database can be accessed and managed via phpMyAdmin or the command line, and it is crucial to back up the database regularly to prevent data loss.

Effects of C++ template specialization on function overloading and overriding Effects of C++ template specialization on function overloading and overriding Apr 20, 2024 am 09:09 AM

C++ template specializations affect function overloading and rewriting: Function overloading: Specialized versions can provide different implementations of a specific type, thus affecting the functions the compiler chooses to call. Function overriding: The specialized version in the derived class will override the template function in the base class, affecting the behavior of the derived class object when calling the function.

How to delete theme template in wordpress How to delete theme template in wordpress Apr 16, 2024 am 02:36 AM

To delete a WordPress theme template, first log into your dashboard, then go to Appearance > Theme Editor, select the theme you want to delete, click Delete and confirm, and optionally activate the new theme.

See all articles