search
HomeCMS TutorialWordPressWhat are the commonly used functions in wordpress templates?

What are the commonly used functions in wordpress templates?

Nov 18, 2019 pm 03:20 PM
wordpressCommonly used functionstemplate

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

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 : 搜索结果模板

2. Basic condition judgment Tag

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页是否以多页显示

3. Header part PHP function

<!–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)的标题

4. Template PHP functions and commands

<!–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 . ‘/文件名’);–>: 嵌入其他文件,可为定制的模板或其他类型文件

5. Other template-related functions

<!–p _e(’Message’);–>: 输出相应信息
<!–p wp_register();–>: 显示注册链接
<!–p wp_loginout();–>: 显示登录/注销链接
<!–ext pag–>: 将当前内容分页
<!–or–>: 将当前内容截断,以不在主页/目录页显示全部内容
<!–p timer_stop(1);–>: 网页加载时间(秒)
<!–p echo get_num_queries();–>: 网页加载查询量

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
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
Can I learn WordPress in 3 days?Can I learn WordPress in 3 days?Apr 09, 2025 am 12:16 AM

Can learn WordPress within three days. 1. Master basic knowledge, such as themes, plug-ins, etc. 2. Understand the core functions, including installation and working principles. 3. Learn basic and advanced usage through examples. 4. Understand debugging techniques and performance optimization suggestions.

Is WordPress a CMS?Is WordPress a CMS?Apr 08, 2025 am 12:02 AM

WordPress is a Content Management System (CMS). It provides content management, user management, themes and plug-in capabilities to support the creation and management of website content. Its working principle includes database management, template systems and plug-in architecture, suitable for a variety of needs from blogs to corporate websites.

What is the WordPress good for?What is the WordPress good for?Apr 07, 2025 am 12:06 AM

WordPressisgoodforvirtuallyanywebprojectduetoitsversatilityasaCMS.Itexcelsin:1)user-friendliness,allowingeasywebsitesetup;2)flexibilityandcustomizationwithnumerousthemesandplugins;3)SEOoptimization;and4)strongcommunitysupport,thoughusersmustmanageper

Should I use Wix or WordPress?Should I use Wix or WordPress?Apr 06, 2025 am 12:11 AM

Wix is ​​suitable for users who have no programming experience, and WordPress is suitable for users who want more control and expansion capabilities. 1) Wix provides drag-and-drop editors and rich templates, making it easy to quickly build a website. 2) As an open source CMS, WordPress has a huge community and plug-in ecosystem, supporting in-depth customization and expansion.

How much does WordPress cost?How much does WordPress cost?Apr 05, 2025 am 12:13 AM

WordPress itself is free, but it costs extra to use: 1. WordPress.com offers a package ranging from free to paid, with prices ranging from a few dollars per month to dozens of dollars; 2. WordPress.org requires purchasing a domain name (10-20 US dollars per year) and hosting services (5-50 US dollars per month); 3. Most plug-ins and themes are free, and the paid price ranges from tens to hundreds of dollars; by choosing the right hosting service, using plug-ins and themes reasonably, and regularly maintaining and optimizing, the cost of WordPress can be effectively controlled and optimized.

Is WordPress still free?Is WordPress still free?Apr 04, 2025 am 12:06 AM

The core version of WordPress is free, but other fees may be incurred during use. 1. Domain names and hosting services require payment. 2. Advanced themes and plug-ins may be charged. 3. Professional services and advanced features may be charged.

Is WordPress easy for beginners?Is WordPress easy for beginners?Apr 03, 2025 am 12:02 AM

WordPress is easy for beginners to get started. 1. After logging into the background, the user interface is intuitive and the simple dashboard provides all the necessary function links. 2. Basic operations include creating and editing content. The WYSIWYG editor simplifies content creation. 3. Beginners can expand website functions through plug-ins and themes, and the learning curve exists but can be mastered through practice.

Why would anyone use WordPress?Why would anyone use WordPress?Apr 02, 2025 pm 02:57 PM

People choose to use WordPress because of its power and flexibility. 1) WordPress is an open source CMS with strong ease of use and scalability, suitable for various website needs. 2) It has rich themes and plugins, a huge ecosystem and strong community support. 3) The working principle of WordPress is based on themes, plug-ins and core functions, and uses PHP and MySQL to process data, and supports performance optimization.

See all articles

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 agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor