The main reason for choosing to use WordPress to build a blog is that WordPress has a high popularity, and there are all kinds of extension functions developed around it. Basically, it can be said that any function we need in blog construction , someone has thought of it and implemented it, so that you don’t have to invest too much energy in the specific technical implementation and functional expansion of your blog, but focus more on content construction.
This article briefly summarizes the basic information of WordPress theme templates in the form of a technical manual, hoping to quench the thirst of friends who develop WordPress theme templates.
WordPress theme template basic files
A complete set of WordPress theme templates should have at least the following files:, WordPress basic template files, WordPress template essential files:
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 : 搜索结果模板
Basic condition judgment Tag
is_home() : 是否为主页 is_single() : 是否为内容页(Post) is_page() : 是否为内容页(Page) is_category() : 是否为Category/Archive页 is_tag() : 是否为Tag存档页 s_date() : 是否为指定日期存档页 is_year() : 是否为指定年份存档页 is_month() : 是否为指定月份存档页 is_day() : 是否为指定日存档页 is_time() : 是否为指定时间存档页 is_archive() : 是否为存档页 is_search() : 是否为搜索结果页 s_404() : 是否为 “HTTP 404: Not Found” 错误页 is_paged() : 主页/Category/Archive页是否以多页显示
PHP functions commonly used in the Header part
<?php bloginfo (’name’); ?> : 博客名称(Title) <?php bloginfo (’stylesheet_url’); ?> : CSS文件路径 <?php bloginfo (’pingback_url’); ?> : PingBack Url <?php bloginfo (’template_url’); ?> : 模板文件路径 <?php bloginfo (’version’); ?> : WordPress版本 <?php bloginfo (’atom_url’); ?> : Atom Url <?php bloginfo (’rss2_url’); ?> : RSS 2.o Url <?php bloginfo (’url’); ?> : 博客 Url <?php bloginfo (’html_type’); ?> : 博客网页Html类型 <?php bloginfo (’charset’); ?> : 博客网页编码 <?php bloginfo (’description’); ?> : 博客描述 <?php wp_title(); ?> : 特定内容页(Post/Page)的标题
PHP functions commonly used in templates And the command
<?php get_header(); ?> : 调用Header模板 <?php get_sidebar(); ?> : 调用Sidebar模板 <?php get_footer(); ?> : 调用Footer模板 <?php the_content(); ?> : 显示内容(Post/Page) <?php the_excerpt(); ?>: 显示摘要 <?php if (have_posts()) : ?> : 检查是否存在Post/Page <?php while (have_posts()) : the_post(); ?> : 如果存在Post/Page则予以显示 <?php endwhile ; ?> : While 结束 <?php endif ; ?> : If 结束 <?php the_time(’字符串’) ?> : 显示时间,时间格式由“字符串”参数决定,具体参考PHP手册 <?php comments_popup_link(); ?> : 正文中的留言链接。如果使用 comments_popup_script() ,则留言会在新窗口中打开,反之,则在当前窗口打开 <?php the_title(); ?> : 内容页(Post/Page)标题 <?php the_permalink() ?> : 内容页(Post/Page) Url <?php the_category(’, ‘) ?> : 特定内容页(Post/Page)所属Category <?php the_author(); ?> : 作者 <?php the_ID(); ?> : 特定内容页(Post/Page) ID <?php edit_post_link(); ?> : 如果用户已登录并具有权限,显示编辑链接 <?php get_links_list(); ?> : 显示Blogroll中的链接 <?php comments_template(); ?> : 调用留言/回复模板 <?php wp_list_pages(); ?> : 显示Page列表 <?php wp_list_categories(); ?> : 显示Categories列表 <?php next_post_link(’ %link ‘); ?> : 下一篇文章链接 <?php previous_post_link(’%link’); ?> : 上一篇文章链接 <?php get_calendar(); ?> : 日历 <?php wp_get_archives() ?> : 显示内容存档 <?php posts_nav_link(); ?> : 导航,显示上一篇/下一篇文章链接 <?php include (TEMPLATEPATH . ‘/文件名’); ?> : 嵌入其他文件,可为定制的模板或其他类型文件
Other functions related to the template
<?php _e(’Message’); ?> : 输出相应信息 <?php wp_register(); ?> : 显示注册链接 <?php wp_loginout(); ?> : 显示登录/注销链接 <–next page–> : 将当前内容分页 <–more–> : 将当前内容截断,以不在主页/目录页显示全部内容 <?php timer_stop(1); ?> : 网页加载时间(秒) <?php echo get_num_queries(); ?> : 网页加载查询量
Others
<?php get_archives(’postbypost’, 10); ?> 调用最近的10篇日志 <?php $rand_posts = get_posts(’numberposts=10&orderby=rand’); foreach ( $rand_posts as $post ) : ?> <li><a href= "”<?php" the_permalink();= "" ?= "" >”> <?php the_title(); ?></a></li> <?php endforeach ; ?>
Randomly call 10 logs
<?php the_tags(’Post Tags :’, ‘, ‘, ‘<br />’); ?> 调用标签 <?php if (get_the_tags()) the_tags(’Tags:’,’,’,’ end ’); ?>
Called when the tag exists
<?php wp_tag_cloud(’smallest=1&largest=9&’); ?> 调用标签云 <?php $posts = get_posts( “category=12&numberposts=4″ ); ?> 获得4篇12分类中的日志
Let’s have some more detailed judgment functions
<?php if (is_single()):?> //这里写你想显示的内容,包括函数 <?php endif ;?>
The following is the direct From wordpress.org
is_single() 判断是否是具体文章的页面 is_single(’17′) 判断是否是具体文章(id=17)的页面 is_single(’Beef Stew’) 判断是否是具体文章(标题判断)的页面 is_single(’beef-stew’) 判断是否是具体文章(slug判断)的页面 comments_open() 是否留言开启 pings_open() 是否开启ping is_page() 是否是页面 is_page(’42′) 同single,id判断,即是否是id为42的页面 is_page(’About Me’) title判断 is_page(’about-me’) slug判断 is_category() 是否是分类 is_category(’6′) 同single,id判断,即是否是id为6的分类 is_category(’Cheeses’) title判断 is_category(’cheeses’) slug判断 in_category(’5′) 判断当前的文章是否属于分类5 is_author() 将所有的作者的页面显示出来 is_author(’1337′) 显示author number为1337的页面 is_author(’Elite Hacker’) 通过昵称来显示当前作者的页面 is_author(’elite-hacker’) is_date() is_year() is_month() is_day() is_time() is_archive() 判断当前是否是归档页面 is_search() 判断是否是搜索 is_404() 判断页面是否404 is_paged() 判断是否翻页,比如你当前的blog是http: //domain.com,显示http: //domain.com?paged=2的时候,这个判断将返回真,通过这个函数可以配合is_home来控制某些只能在首页显示的界面,例如: if (is_home() && !is_paged()
The above is the detailed content of Summary of commonly used functions and methods in WordPress. For more information, please follow other related articles on the PHP Chinese website!

What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

PHP and Python are both high-level programming languages that are widely used in web development, data processing and automation tasks. 1.PHP is often used to build dynamic websites and content management systems, while Python is often used to build web frameworks and data science. 2.PHP uses echo to output content, Python uses print. 3. Both support object-oriented programming, but the syntax and keywords are different. 4. PHP supports weak type conversion, while Python is more stringent. 5. PHP performance optimization includes using OPcache and asynchronous programming, while Python uses cProfile and asynchronous programming.

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP remains important in the modernization process because it supports a large number of websites and applications and adapts to development needs through frameworks. 1.PHP7 improves performance and introduces new features. 2. Modern frameworks such as Laravel, Symfony and CodeIgniter simplify development and improve code quality. 3. Performance optimization and best practices further improve application efficiency.

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values and handle functions that may return null values.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver Mac version
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version
Useful JavaScript development tools