完整的WordPress函数大全

合集下载

wordpress函数说明(已汉化中文)

wordpress函数说明(已汉化中文)
get_the_author
获取文章的标签ID.
get_the_content
获取文章的内容,$more_link_text 是更多的链接文字, $stripteaser 在更多内容前显示内容摘要, $more_file 可选,不使用.
wp_trim_excerpt
必要时为文章生成内容摘要. 摘要应在55字以内,如果总字数多于该数目,摘要结尾应添加字符串’[...]‘。如果少于55个字符,显示摘要全文。
wp_get_attachment_image_src
返回一个附件的src,$attachment_id是附件ID,$size是(thumbnail, medium, large or full),$icon 是替代的图标地址.
wp_get_attachment_metadata
返回一个附件的元数据,$post_id是附件ID,$unfiltered判断是否使用过滤器.
wp_get_recent_posts
返回最近发布的文章数组.
wp_get_single_post
返回单篇文章的的数组或对象,同get_post().
wp_delete_post
删除文章、页面或附件,$force_delete为true时不经过回收站.
wp_insert_post
is_post
已弃用.
is_single
判断是否规定的单篇日志.
is_sticky
判断文章是否置顶.
register_post_type
注册发布类型,详情见:/Function_Reference/register_post_type.
wp_delete_attachment

wordpress常用标签调用代码大全

wordpress常用标签调用代码大全

和之间的PHP代码网站标题日志或页面标题WordPress主题样式表文件style.css的相对地址WordPress博客的Pingback地址WordPress主题文件的相对地址博客的Wordpress版本WordPress博客的Atom地址WordPress博客的RSS2地址WordPress博客的绝对地址WordPr ess博客的名称网站的HTML版本网站的字符编码格式WordPress 主体模板PHP代码日志内容确认是否有日志如果有,则显示全部日志结束PHP函数”while”结束PHP函数”if”header.php文件的内容sidebar.php文件的内容footer.php文件的内容显示格式为”02-19-08″的日期显示一篇日志的留言链接显示一篇日志或页面的标题显示一篇日志或页面的永久链接/URL地址显示一篇日志或页面的所属分类显示一篇日志或页面的作者显示一篇日志或页面的ID显示一篇日志或页面的编辑链接显示Blogroll中的链接comments.php文件的内容显示一份博客的页面列表显示一份博客的分类列表下一篇日志的URL地址上一篇日志的URL地址调用日历显示一份博客的日期存档列表显示较新日志链接(上一页)和较旧日志链接(下一页)显示博客的描述信息其它的一些Wordpress模板代码/%postname%/ 显示博客的自定义永久链接搜索表单的值打印输出信息显示注册链接显示登入/登出链接在日志或页面中插入分页截断日志显示管理员的相关控制信息显示载入页面的时间显示载入页面查询1. wordpress调用最新文章WordPress最新文章的调用可以使用一行很简单的模板标签wp_get_archvies来实现. 代码如下:(显示10篇最新更新文章)或者后面这个代码显示你博客中最新的20篇文章,其中format=custom这里主要用来自定义这份文章列表的显示样式。

具体的参数和使用方法你可以参考官方的使用说明- wp_get_archvies。

wp函数运算公式示例

wp函数运算公式示例

wp函数运算公式示例
以下是WP表格中常用函数的运算公式示例:
1.SUM函数:SUM函数用于求和,可以计算连续区域或不连续区域单元格的数值之和。

例如,在单元格A1中输入公式=SUM(B1:B10),可以将B1到B10单元格中的数值相加。

2.COUNT函数:COUNT函数用于计数,可以计算单元格区域或数字数组中数字字段的输入项个数。

例如,在单元格A1中输入公式=COUNT(B1:B10),可以统计B1到B10单元格中数字的数量。

3.COUNTIF函数:COUNTIF函数用于对满足特定条件的单元格进行计数。

例如,在单元格A1中输入公式
=COUNTIF(B1:B10,">50"),可以统计B1到B10单元格中数值大于50的数量。

4.AVERAGE函数:AVERAGE函数用于计算平均值,可以计算连续区域或不连续区域单元格内的数值之和,然后除以单元格的数量。

例如,在单元格A1中输入公式
=AVERAGE(B1:B10),可以计算B1到B10单元格中的平均值。

5.MAX函数:MAX函数用于找出最大值,可以计算连续区域或不连续区域单元格中的最大值。

例如,在单元格A1中输入公式=MAX(B1:B10),可以找出B1到B10单元格中的最大值。

6.MIN函数:MIN函数用于找出最小值,可以计算连续区域或不连续区域单元格中的最小值。

例如,在单元格A1中输入公式=MIN(B1:B10),可以找出B1到B10单元格中的最小值。

以上示例可以帮助您理解WPS表格中常用的函数运算公式,具体使用时需要根据实际情况进行修改和调整。

wordpress模板标签函数大全二次开发手册

wordpress模板标签函数大全二次开发手册

1.根据分类来制定导航条2.删除控制面板首页多余的板块3.显示所有最新的文章4.发表文章时对文章进行修改的操作一套完整的WordPress模板应至少具有如下文件: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 : 搜索结果模板当然,具体到特定的某款模板,可能不止这些文件,但一般而言,这些文件是每套模板所必备的。

基本条件判断Tagis_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 Foun d” 错误页is_paged() : 主页/Category/Archive页是否以多页显示Header部分常用到的PHP函数<?php blog info(‟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函数及命令<?php get_header(); ?> : 调用Header模板<?php get_sidebar(); ?> : 调用Sidebar模板<?php get_footer(); ?> : 调用Footer模板<?php the_content(); ?> : 显示内容(Post/Page)<?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(); ?> : 正文中的留言链接。

WORDPRESS函数使用说明

WORDPRESS函数使用说明

WORDPRESS函数使用说明WordPress是一个非常流行的开源内容管理系统(CMS),它提供了丰富的功能和灵活的扩展性,使得用户可以轻松创建和管理自己的网站。

WordPress的功能主要是通过函数调用来实现的,函数提供了许多方便的方法来完成各种任务,包括创建页面、发布文章、添加插件、更改主题等。

在这篇文章中,我们将详细介绍一些常用的WordPress函数,以及它们的使用说明。

1. get_header(和get_footer(: 这两个函数用于在页面中引入网站的头部和底部。

可以将它们放置在页面的适当位置,以保证每个页面都有一致的布局和样式。

2. bloginfo(: 这个函数用于输出网站的基本信息,比如网站的名称、描述、URL等。

可以使用不同的参数来获取不同的信息,比如bloginfo('name')将输出网站的名称,bloginfo('description')将输出网站的描述。

3. wp_nav_menu(: 这个函数用于创建自定义菜单。

可以通过在WordPress后台创建菜单,并给菜单分配位置,然后使用wp_nav_menu(函数将菜单输出到指定位置。

4. get_sidebar(: 这个函数用于引入侧边栏的内容。

可以将它放置在页面的适当位置,以显示一些附加的信息、小工具或广告。

6. the_loop(: 这个函数用于循环输出查询结果。

通常配合wp_query(函数一起使用,可以在循环中使用其他函数来输出文章的标题、内容、缩略图等信息。

7. get_permalink(: 这个函数用于获取文章或页面的永久链接。

可以使用这个函数来生成自定义的链接,比如在文章列表中添加“阅读全文”链接。

8. the_title(和the_content(: 这两个函数分别用于输出文章或页面的标题和内容。

可以将它们放置在循环中,以逐个输出查询结果。

9. the_post_thumbnail(: 这个函数用于输出文章或页面的特色图像。

WordPress分类函数get_categories(获得分类所有信息)-推荐下载

WordPress分类函数get_categories(获得分类所有信息)-推荐下载

用get_categories()函数代替wp_list_categories()灵活显示分类列表的例子我们在开发wordpres主题时一般都是wp list categories()显示分类列表,但是有时我们不想要class,title之类的,那么我们可以用wordpress中的get_categories()定制自己的样式,例如下面的例子就可以生成我们需要的最简单样式,当然你还可以按自己的要求编写get_categories()函数可以获得分类所有信息,返回与查询参数相匹配的类别对象数组。

变量与wp_list_categories基本一致,且变量可被作为数组传递,也可在查询句法中被传递。

函数说明用法:参数说明∙type(字符)post和link 其中link在新版3.0以后已被弃用。

∙child_of(整数)仅显示标注了编号的分类的子类。

该参数无默认值。

使用该参数时应将hide_empty 参数设为false∙parent(整数)只显示某个父级分类以及下面的子分类(注:子分类只显示一个层级)。

∙orderby(字符)将分类按字母顺序或独有分类编号进行排序。

默认为按分类编号排序包括ID(默认)和Name∙order(字符)为类别排序(升序或降序)。

默认升序。

可能的值包括asc(默认)和desc∙hide_empty(布尔值)触发显示没有文章的分类。

默认值为true(隐藏空类别)。

有效的值包括:1(true)和0(false)。

∙hierarchical(布尔值)将子类作为内部列表项目(父列表项下)的层级关系。

默认为true(显示父列表项下的子类)。

有效值包括1 (true)和0(false)∙exclude(字符)除去分类列表中一个或多个分类,多个可以用逗号分开,用分类ID号表示。

∙include(字符)只包含指定分类ID编号的分类。

多个可以用逗号分开,用分类ID号表示。

∙pad_counts(布尔值)通过子类中的项来计算链接或文章。

遍历 obregistercallbacks 的回调函数-概述说明以及解释

遍历 obregistercallbacks 的回调函数-概述说明以及解释

遍历obregistercallbacks 的回调函数-概述说明以及解释1.引言1.1 概述引言部分的概述旨在介绍读者对于接下来要讨论的话题有一个整体的认识。

在本篇文章中,我们将深入探讨obregistercallbacks 这个函数的回调函数,介绍其作用、遍历方法和回调函数的重要性。

通过分析这些内容,读者可以更加全面地了解如何有效地利用这些功能来实现程序的高效性和可维护性。

通过本文的阐述,读者将能够掌握关于obregistercallbacks 的回调函数的相关知识,为日后的实际应用提供参考和指导。

1.2文章结构1.2 文章结构本文将分为三个主要部分:引言、正文和结论。

引言部分将介绍obregistercallbacks 的概念和作用,以及本文的目的。

正文部分将深入探讨obregistercallbacks 的作用、遍历obregistercallbacks 的方法以及回调函数的重要性。

结论部分将总结本文的主要观点,并探讨obregistercallbacks 在实际应用中的场景和未来发展的展望。

通过这三个部分的内容,读者将能够全面了解obregistercallbacks 的特点和作用,以及如何有效地使用和管理其回调函数。

"1.3 目的":本文的目的是深入探讨obregistercallbacks 的回调函数,并介绍遍历这些回调函数的方法。

通过本文的阐述,读者将能够清晰地了解obregistercallbacks在代码中的作用和重要性,掌握如何利用回调函数来实现特定功能。

同时,本文还将分析回调函数在实际应用场景中的作用,以及展望未来回调函数的发展趋势,帮助读者更好地应用和理解这一重要的编程概念。

通过全面而深入的研究,读者将能够更好地掌握回调函数的使用方法,提高代码的可读性和可维护性,从而在实践中更好地运用这一技术。

2.正文2.1 obregistercallbacks 的作用obregistercallbacks 是一个函数,它的作用是注册一个或多个回调函数,这些回调函数会在特定事件发生时被调用。

wordpress函数大全列表整理

wordpress函数大全列表整理

wordpress函数⼤全列表整理wordpress有很多的函数可供调⽤,下⾯ytkah就整理了⼀下wordpress函数⼤全供各位参考,如果要详情,可以访问https:///reference/functions/参数名/,感兴趣的朋友可以收藏⽂章,页⾯,附件,书签⽂章get_adjacent_postget_boundary_postget_childrenget_extendedget_next_postget_next_posts_linknext_posts_linkget_permalinkthe_permalinkget_the_excerptthe_excerptget_the_post_thumbnailget_postget_post_fieldget_post_ancestorsget_post_mime_typeget_post_statusget_post_formatset_post_formatget_delete_post_linkget_previous_postget_previous_posts_linkprevious_posts_linkhave_postsis_post(不赞成)is_singleis_stickyget_the_IDthe_IDthe_postwp_get_recent_postswp_get_single_posthas_post_thumbnailhas_excerpthas_post_format⾃定义⽂章状态register_post_status⾃定义⽂章类型register_post_typeis_post_type_archivepost_type_archive_titleadd_post_type_supportremove_post_type_supportpost_type_supportsset_post_typepost_type_existsget_post_typeget_post_typesget_post_type_archive_linkget_post_type_objectget_post_type_capabilitiesget_post_type_labelsis_post_type_hierarchical⽂章插⼊/移除lwp_delete_postwp_insert_postwp_publish_postwp_trash_postwp_update_post页⾯get_all_page_idsget_ancestorsget_page(不赞成)get_page_linkget_page_by_pathget_page_by_titleget_page_childrenget_page_hierarchyget_page_uriget_pagesis_pagepage_uri_indexwp_link_pageswp_dropdown_pages⾃定义域 (⽂章信息 postmeta)add_post_metadelete_post_metaget_post_customget_post_custom_keysget_post_custom_valuesget_post_metaupdate_post_metaregister_meta附件get_attached_fileimage_resize(不赞成)is_attachmentis_local_attachmentset_post_thumbnailupdate_attached_filewp_attachment_is_imagewp_create_thumbnail(不赞成)wp_insert_attachmentwp_delete_attachmentwp_get_attachment_imagewp_get_attachment_linkwp_get_attachment_image_srcwp_get_attachment_metadatawp_get_attachment_thumb_filewp_get_attachment_thumb_urlwp_get_attachment_urlwp_check_for_changed_slugswp_count_postswp_get_mime_typeswp_mime_type_iconwp_generate_attachment_metadata wp_prepare_attachment_for_jswp_update_attachment_metadata 书签(链接)get_bookmarkget_bookmarkswp_get_post_categories条件项wp_set_post_categorieswp_get_post_tagswp_set_post_tagswp_get_post_termswp_set_post_termswp_count_termshas_termis_object_in_term其他add_meta_boxremove_meta_boxget_the_IDthe_IDget_the_authorthe_authorget_the_author_posts get_the_contentthe_contentget_the_titlethe_titlethe_title_attributewp_trim_excerptwp_get_post_revision wp_get_post_revisions wp_is_post_revision paginate_links分类,标签,分类法分类cat_is_ancestor_ofget_all_category_idsget_ancestorsget_cat_IDget_cat_nameget_categoriesget_categoryget_category_by_path get_category_by_slug get_the_category_by_ID get_the_category_list get_category_linkget_category_parents get_the_categorysingle_cat_titlein_categoryis_categorythe_categorywp_category_checklist wp_dropdown_categories wp_list_categories分类创建wp_create_categorywp_delete_categorywp_insert_category标签get_tagget_tag_linkget_tagsget_the_tag_listget_the_tagshas_tagis_tagthe_tagssingle_tag_titletag_descriptionwp_generate_tag_cloud wp_tag_cloud分类法get_object_taxonomiesget_edit_term_linkget_edit_term_linkget_taxonomyget_taxonomiesget_termget_the_term_listget_term_bythe_termsget_the_termsget_term_childrenget_term_linkget_termsis_taxonomyis_taxonomy_hierarchicalis_term(不赞成)taxonomy_existsterm_existsregister_taxonomyregister_taxonomy_for_object_type wp_get_object_termswp_remove_object_termswp_set_object_termswp_insert_termwp_update_termwp_delete_termwp_terms_checklist⽤户、作者及权限权限add_capadd_roleauthor_cancurrent_user_cancurrent_user_can_for_blogget_roleget_super_adminsis_super_adminmap_meta_capremove_capremove_roleuser_can⽤户和作者auth_redirectcount_userscount_user_postscount_many_users_postsemail_existsget_currentuserinfoget_current_user_idget_profile(不赞成)get_user_byget_userdataget_usernumposts(不赞成)get_usersset_current_user(不赞成)user_pass_ok(不赞成)wp_authenticateusername_existsvalidate_usernamewp_dropdown_userswp_get_current_userwp_set_current_userwp_set_passwordget_author_posts_urlget_the_modified_authoris_multi_author⽤户 metaadd_user_metadelete_user_metaget_user_metaupdate_user_metaget_the_author_meta⽤户添加和删除wp_create_userwp_delete_userwp_insert_userwp_update_user登录和注销is_user_logged_inwp_login_formwp_signonwp_logoutwp_loginout供稿(Feed)bloginfo_rsscomment_author_rsscomment_linkcomment_text_rssdo_feeddo_feed_atomdo_feed_rdfdo_feed_rssdo_feed_rss2fetch_feedfetch_rss(不赞成)get_author_feed_linkget_bloginfo_rssget_category_feed_linkget_comment_linkget_comment_author_rssget_post_comments_feed_link get_rss(不赞成)get_search_comments_feed_link get_search_feed_linkget_the_category_rssget_the_title_rsspost_comments_feed_linkrss_enclosurethe_title_rssthe_category_rssthe_content_rss(不赞成)the_excerpt_rsswp_rss(不赞成)评论,通知和引⽤(Ping,Trackback) add_pingadd_comment_metacheck_commentcomment_textcomment_formcomments_numberdiscover_pingback_server_uri delete_comment_metado_all_pingsdo_enclosedo_trackbacksgeneric_pingget_approved_commentsget_avatarget_commentget_comment_textget_comment_metaget_commentswp_list_commentsget_enclosedget_lastcommentmodifiedget_pungget_to_pinghave_commentsget_comment_authoris_trackbackpingbackprivacy_ping_filtersanitize_comment_cookies trackbacktrackback_urltrackback_url_listupdate_comment_metaweblog_pingwp_allow_commentwp_count_commentswp_delete_commentwp_filter_commentwp_get_comment_statuswp_get_current_commenterwp_insert_commentwp_new_commentwp_set_comment_statuswp_throttle_comment_floodwp_update_commentwp_update_comment_countwp_update_comment_count_now 评论循环comment_classcomment_IDcomment_authorcomment_datecomment_timeget_comment_dateget_comment_time评论分页paginate_comments_links previous_comments_linknext_comments_linkget_comment_pages_count远程(remote)wp_remote_getwp_remote_retrieve_bodywp_get_http_headerswp_remote_fopen动作(Action),过滤器(Filter)和插件过滤器has_filteradd_filterapply_filtersapply_filters_ref_arraycurrent_filtermerge_filtersremove_filterremove_all_filters动作has_actionadd_actiondo_actiondo_action_ref_arraydid_actionremove_actionremove_all_actions插件plugin_basenameplugins_urlget_plugin_dataget_admin_page_titleplugin_dir_pathregister_activation_hookregister_deactivation_hookmenu_page_urlis_plugin_activeis_plugin_active_for_networkis_plugin_inactiveis_plugin_pageadd_contextual_help(不赞成)get_plugins⼩⼯具is_active_widgetregister_widgetthe_widgetunregister_widgetwp_add_dashboard_widgetwp_convert_widget_settingswp_get_sidebars_widgets(不赞成)wp_get_widget_defaultswp_register_sidebar_widgetwp_register_widget_controlwp_set_sidebars_widgets(不赞成)wp_unregister_sidebar_widgetwp_unregister_widget_controlwp_widget_description设置register_settingunregister_settingsettings_fieldsdo_settings_fieldsdo_settings_sectionsadd_settings_fieldadd_settings_sectionadd_settings_errorget_settings_errorssettings_errors短标签add_shortcodedo_shortcodedo_shortcode_tag(不赞成)get_shortcode_regexremove_shortcoderemove_all_shortcodesshortcode_attsshortcode_parse_attsstrip_shortcodes主题相关Include 函数comments_templateget_footerget_headerget_sidebarget_search_form其他函数add_custom_backgroundadd_custom_image_header(不赞成)add_image_sizeadd_theme_supportbody_classcurrent_theme_supportsdynamic_sidebarget_404_templateget_archive_templateget_attachment_templateget_author_templateget_body_classget_category_templateget_comments_popup_templateget_current_themeget_date_templateget_header_imageget_header_textcolorget_home_templateget_locale_stylesheet_uriget_page_templateget_paged_templateget_post_classget_query_templateget_search_templateget_single_templateget_stylesheetget_stylesheet_directoryget_stylesheet_directory_uriget_stylesheet_uriget_tag_templateget_taxonomy_templateget_templateget_template_directoryget_template_directory_uriget_template_partget_theme(不赞成)wp_get_themesget_theme_data(不赞成)get_theme_supportget_theme_modget_theme_modsget_theme_rootget_theme_rootsget_theme_root_uriget_themes(不赞成)has_header_imageheader_imageheader_textcolorin_the_loopis_child_themeis_active_sidebaris_admin_bar_showingis_customize_previewis_dynamic_sidebarlanguage_attributesload_templatelocale_stylesheetlocate_templatepost_classpreview_themepreview_theme_ob_filter preview_theme_ob_filter_callback register_nav_menuregister_nav_menusget_registered_nav_menuswp_create_nav_menuregister_sidebarregister_sidebarsregister_theme_directory remove_theme_modremove_theme_modsremove_theme_supportrequire_if_theme_supports search_theme_directoriesset_theme_modswitch_themevalidate_current_theme unregister_nav_menu unregister_sidebarwp_add_inline_stylewp_clean_themes_cachewp_get_archiveswp_get_nav_menu_itemswp_get_themewp_nav_menuwp_oembed_remove_provider wp_page_menuwp_title格式化(Formatting)absintadd_magic_quotes addslashes_gpcantispambotattribute_escapebackslashitbalanceTagsclean_preclean_url(不赞成)convert_charsconvert_smiliesent2ncresc_attresc_htmlesc_jsesc_textareaesc_sqlesc_urlesc_url_rawforce_balance_tagsformat_to_editformat_to_post(不赞成)funky_javascript_fix htmlentities2is_emailjs_escape(不赞成)make_clickablepopuplinksremove_accentssanitize_emailsanitize_file_namesanitize_html_classsanitize_keysanitize_mime_type sanitize_optionsanitize_sql_orderby sanitize_text_fieldsanitize_titlesanitize_title_for_query sanitize_title_with_dashes sanitize_userseems_utf8stripslashes_deep trailingslashit untrailingslashiturlencode_deepurl_shortenutf8_uri_encodewpautopwptexturizewp_filter_kseswp_filter_post_kseswp_filter_nohtml_kseswp_iso_descramblerwp_kseswp_kses_array_lcwp_kses_attrwp_kses_bad_protocolwp_kses_bad_protocol_once wp_kses_bad_protocol_once2 wp_kses_check_attr_valwp_kses_decode_entitieswp_kses_hairwp_kses_hookwp_kses_html_errorwp_kses_js_entitieswp_kses_no_nullwp_kses_normalize_entities wp_kses_normalize_entities2 wp_kses_splitwp_kses_split2wp_kses_strip_slasheswp_kses_versionwp_make_link_relativewp_normalize_pathwp_rel_nofollowwp_richedit_prewp_specialcharswp_trim_wordszeroisecurrent_timedate_i18nget_calendarget_date_from_gmtget_lastpostdateget_lastpostmodifiedget_day_linkget_gmt_from_dateget_month_linkthe_dateget_the_datethe_timeget_the_timethe_modified_timeget_the_modified_timeget_weekstartendget_year_linkhuman_time_diffiso8601_timezone_to_offset iso8601_to_datetime mysql2date序列化is_serializedis_serialized_string maybe_serializemaybe_unserialize选项add_optionadd_site_optiondelete_optiondelete_site_optionform_optionget_alloptions(不赞成)get_site_optionget_site_urlget_admin_urlget_user_optionget_optionupdate_optionupdate_site_option update_user_optionwp_load_alloptions Transientsset_transientget_transientdelete_transientset_site_transientget_site_transientdelete_site_transient后台菜单add_menu_pageremove_menu_pageadd_submenu_page remove_submenu_page add_object_pageadd_utility_pageadd_comments_pageadd_dashboard_pageadd_links_pageadd_management_page add_media_pageadd_options_pageadd_pages_pageadd_plugins_pageadd_posts_pageadd_theme_pageadd_users_page⼯具栏add_groupget_nodeget_nodes表单帮助checkeddisabledselectedsubmit_buttonget_submit_buttonNonces and Refererscheck_admin_referercheck_ajax_refererwp_create_noncewp_explain_nonce(不赞成)wp_get_original_refererwp_get_refererwp_nonce_ayswp_nonce_fieldwp_nonce_urlwp_original_referer_fieldwp_referer_fieldwp_send_jsonwp_send_json_errorwp_send_json_successwp_verify_nonceXMLRPCxmlrpc_getpostcategory xmlrpc_getposttitlexmlrpc_removepostdatauser_pass_ok(不赞成)本地化___x_n_nx_e_ex__ngettextesc_attr__esc_attr_eget_localeload_default_textdomain load_plugin_textdomainload_textdomainload_theme_textdomainis_rtl定时spawn_cronwp_clear_scheduled_hook wp_cronwp_get_schedulewp_get_scheduleswp_next_scheduledwp_reschedule_eventwp_schedule_eventwp_schedule_single_event wp_unschedule_eventwp_dequeue_scriptwp_dequeue_stylewp_deregister_scriptwp_deregister_stylewp_enqueue_scriptwp_enqueue_stylewp_localize_scriptwp_register_scriptwp_register_stylewp_script_iswp_style_isSQLget_tax_sqlget_meta_sqlget_posts_by_author_sql杂项add_editor_styleadd_query_argadmin_urlbool_from_yncache_javascript_headers capital_P_dangitclean_blog_cachecontent_urldo_robotsflush_rewrite_rulesget_bloginfoget_num_queriesget_post_statiget_post_statusesget_query_varhome_urlincludes_urlis_blog_installedis_main_siteis_main_queryis_multisiteis_sslis_wp_errorlog_app(不赞成)make_url_footnote(不赞成)network_admin_url network_home_urlnetwork_site_urlnocache_headersplugin_dir_urlquery_postsremove_query_argrewind_postssetup_postdatasite_urlstatus_headerunzip_filevalidate_filevalidate_file_to_editwpwp_cache_setwp_cache_getwp_cache_reset(不赞成)wp_check_filetypewp_clearcookiewp_diewp_editorwp_footerwp_get_cookie_login(不赞成)wp_get_image_editorwp_get_installed_translationswp_hashwp_handle_sideloadwp_headwp_install_defaultswp_is_mobilewp_mailwp_mkdir_pwp_new_user_notificationwp_password_change_notificationwp_notify_moderatorwp_notify_postauthorwp_parse_argswp_redirectwp_reset_postdatawp_reset_querywp_saltwp_set_auth_cookiewp_safe_redirectwp_upload_bitswp_upload_dirwp_list_pluckwp_text_diffpost_submit_meta_boxpings_openis_page_templateis_authorlike_escape多站点管理员confirm_delete_usersis_user_member_of_blogwp_dashboard_quotaadmin_notice_feed(不赞成)avoid_blog_page_permalink_collision check_import_new_userscheck_upload_sizechoose_primary_blogdisplay_space_usagefix_import_form_sizeformat_code_langget_site_allowed_themesgrant_super_adminms_deprecated_blogs_filemu_dropdown_languagesnew_user_email_admin_noticeredirect_user_to_blogrefresh_user_detailsrevoke_super_adminsecret_salt_warningsend_confirmation_on_profile_email show_post_thumbnail_warning(不赞成)site_admin_noticesync_category_tag_slugsupdate_option_new_admin_email update_user_statusupload_is_user_over_quotaupload_space_settingwpmu_delete_blogwpmu_delete_userwpmu_get_blog_allowedthemes_admin_notice_multisite_activate_plugins_page 其他⽅法add_blog_optiondelete_blog_optionget_blogaddress_by_domainget_blogaddress_by_idget_blogaddress_by_nameget_blog_detailsget_blog_optionget_blog_statusget_id_from_blognameget_last_updatedis_archivedrefresh_blog_detailsrestore_current_blogswitch_to_blogupdate_archivedupdate_blog_detailsupdate_blog_optionupdate_blog_statuswpmu_update_blogs_datems_cookie_constantsms_file_constantsms_subdomain_constantsms_upload_constantsadd_existing_user_to_blogadd_new_user_to_blogadd_user_to_blogcheck_upload_mimescreate_empty_blogdomain_existsfilter_SSLfix_phpmailer_messageidforce_ssl_contentget_active_blog_for_userget_admin_users_for_domainget_blogs_of_userget_blog_countget_blog_id_from_urlget_blog_permalinkget_blog_postget_current_siteget_dashboard_blogget_dirsizeget_most_recent_post_of_userget_sitestatsget_space_allowedget_space_usedget_upload_space_availableget_user_countget_user_id_from_string(不赞成)global_termsinsert_bloginstall_bloginstall_blog_defaultsis_blog_user(不赞成)is_email_address_unsafeis_upload_space_availableis_user_option_localis_user_spammymaybe_add_existing_user_to_blogmaybe_redirect_404newblog_notify_siteadminnewuser_notify_siteadminrecurse_dirsizeredirect_this_siteremove_user_from_blogsignup_nonce_checksignup_nonce_fieldsupdate_blog_publicupdate_posts_countupload_is_file_too_bigupload_is_user_over_quota upload_size_limit_filterusers_can_register_signup_filter welcome_user_msg_filterwp_get_siteswpmu_activate_signupwpmu_create_blogwpmu_create_userwpmu_log_new_registrations wpmu_signup_blogwpmu_signup_blog_notification wpmu_signup_userwpmu_signup_user_notification wpmu_validate_blog_signup wpmu_validate_user_signup wpmu_welcome_notification wpmu_welcome_user_notification get_current_site_name(不赞成)is_subdomain_installms_not_installedms_site_checkwpmu_current_site(不赞成)。

WordPress主题模板层次和常用模板函数

WordPress主题模板层次和常用模板函数
WordPress主题模板层次和常用模板函数
n'); ?> : 博客描述 <?php wp_title(); ?> : 特定内容页(Post/Page)的标 题 WordPres
WordPress主题模板层次和常用模板函数
s主题 - 模板常用的PHP函数 <?php get_header(); ?> : 调用Header模板 <?php get_side
WordPress主题模板层次和常用模板函数
404() : 是否为 “HTTP 404: Not Found” 错误页 is_paged() : 主页/Category/Arch
WordPress主题模板层次和常用模板函数
ive页是否以多页显示 上面的判断Tag在WordPress主题里常常应用于侧边栏( sidebay)模板文件,就比如 is_home()
WordPress主题模板层次和常用模板函数
,例如你放了一段广告代码在侧边栏上,而又只想在主 页上显示这个广告,那么就可以用到这个判断Tag了。 WordPress主题 – Head
WordPress主题模板层次和常用模板函数
er 常用PHP函数 <?php bloginfo('name'); ?> : 博客名称(Title) <?php bloginfo(
WordPress主题模板层次和常用模板函数
TEMPLATEPATH . '/文件名'); ?> : 嵌入其他文件,可为 定制的模板或其他类型文件 WordPress主题 - 与模板相
WordPress主题模板层次和常用模板函数
关的其他函数 <?php _e('Message'); ?> : 输出相应信息 <?php wp_register(); ?> : 显示

WordPresss数据字典&手册中文版

WordPresss数据字典&手册中文版

用WordPress来建站,我也还是初学者,下面这些模板代码对我们这些初学者来说还是挺有用的,偶尔也会对模板做些修改。

WordPress模板基本文件style.css 样式表文件index.php 主页文件single.php 日志单页文件page.php 页面文件archvie.php 分类和日期存档页文件searchform.php 搜索表单文件search.php 搜索页面文件comments.php 留言区域文件(包括留言列表和留言框)404.php 404错误页面header.php 网页头部文件sidebar.php 网页侧边栏文件footer.php 网页底部文件WordPress Header头部PHP代码注: 也就是位于<head>和</head>之间的PHP代码<?php bloginfo(’name’); ?> 网站标题<?php wp_title(); ?> 日志或页面标题<?php bloginfo(’stylesheet_url’); ?> WordPress主题样式表文件style.css的相对地址<?php bloginfo(’pingback_url’); ?> WordPress博客的Pingback地址<?php bloginfo(’template_url’); ?> WordPress主题文件的相对地址<?php bloginfo(’version’); ?> 博客的Wordpress版本<?php bloginfo(’atom_url’); ?> WordPress博客的Atom地址<?php bloginfo(’rss2_url’); ?> WordPress博客的RSS2地址<?php bloginfo(’url’); ?> WordPress博客的绝对地址<?php bloginfo(’name’); ?> WordPress博客的名称<?php bloginfo(’html_type’); ?> 网站的HTML版本<?php bloginfo(’charset’); ?> 网站的字符编码格式WordPress 主体模板PHP代码<?php the_content(); ?> 日志内容<?php if(have_posts()) : ?> 确认是否有日志<?php while(have_posts()) : the_post(); ?> 如果有,则显示全部日志<?php endwhile; ?> 结束PHP函数”while”<?php endif; ?> 结束PHP函数”if”<?php get_header(); ?> header.php文件的内容<?php get_sidebar(); ?> sidebar.php文件的内容<?php get_footer(); ?> footer.php文件的内容<?php the_time(’m-d-y’) ?> 显示格式为”02-19-08″的日期<?php comments_popup_link(); ?> 显示一篇日志的留言链接<?php the_title(); ?> 显示一篇日志或页面的标题<?php the_permalink() ?> 显示一篇日志或页面的永久链接/URL地址<?php the_category(’, ‘) ?> 显示一篇日志或页面的所属分类<?php the_author(); ?> 显示一篇日志或页面的作者<?php the_ID(); ?> 显示一篇日志或页面的ID<?php edit_post_link(); ?> 显示一篇日志或页面的编辑链接<?php get_links_list(); ?> 显示Blogroll中的链接<?php comments_template(); ?> comments.php文件的内容<?php wp_list_pages(); ?> 显示一份博客的页面列表<?php wp_list_cats(); ?> 显示一份博客的分类列表<?php next_post_link(’%link ‘) ?> 下一篇日志的URL地址<?php previous_post_link(’%link’) ?> 上一篇日志的URL地址<?php get_calendar(); ?> 调用日历<?php wp_get_archives() ?> 显示一份博客的日期存档列表<?php posts_nav_link(); ?> 显示较新日志链接(上一页)和较旧日志链接(下一页)<?php bloginfo(’description’); ?> 显示博客的描述信息其它的一些Wordpress模板代码/%postname%/ 显示博客的自定义永久链接<?php the_search_query(); ?> 搜索表单的值<?php _e(’Message’); ?> 打印输出信息<?php wp_register(); ?> 显示注册链接<?php wp_loginout(); ?> 显示登入/登出链接<!–next page–> 在日志或页面中插入分页<!–more–> 截断日志<?php wp_meta(); ?> 显示管理员的相关控制信息<?php timer_stop(1); ?> 显示载入页面的时间<?php echo get_num_queries(); ?> 显示载入页面查询分析版本:WordPress 3.0USERS表:保存用户信息POSTS表:保存post信息这个表中保存的不只是日志的信息,还有附件和页面(page)的信息,表里的post_type 就是表示类型的。

wordpress主题开发文档

wordpress主题开发文档

1、 WordPress 执行顺序注:可以使用的常量:网站文件根目录绝对路径: ABSPATH;网站文件的wp-content 目录绝对路径:WP_CONTENT_DIR ;网站文件的语言文件目录绝对路径WP_LANG_DIR网站文件的插件目录绝对路径WP_PLUGIN_DIR网站的wp-content 目录的url :WP_CONTENT_URL ;网站的插件plugins 目录的url: WP_PLUGIN_URL ;网站的wp-includes 目录绝对路径:ABSPATH . WPINC当前正在使用的主题的模板所在目录路径:TEMPLATEPATH当前正在使用的模板样式所在目录路径:STYLESHEETPATH(其他常量参考:wp-settings.php )2、 资源: 、3、 WordPress 的模板体系上图是wordpress内置调用模板体系。

4、利用模板标签在模板中输出相应数据。

4.1 主题模板页面中文章循环输出(the loop)Wordpress用the loop来输出获取的文章列表(posts)中的每一篇文章。

在loop内部利用相应的模板标签可以输出一篇博文相关的任何东西,比如标题,作者,发表时间,内容,摘要,标签(tag),所属类别(栏目,category)等等。

同时可以利用任何html,css,php来格式化这些数据。

the loop可以用在任何模板文件中用于输出具体的文章和页面。

比如index.php, category.php, tag.php等等。

(下面的所用介绍都是基于使用内置模板文件)4.2 主题模板中循环输出的一般语句格式:(模板页面内默认采用$wp_query根据访问链接参数获得的查询结果)4.3 自定义查询结果Wordpress在主题模板中提供了至少三种自定义查询方式,用于在输出的模板页面中直接从数据库查询相关文章,构建自定义的循环输出(the loop)。

WordPress中的shortcode短代码功能使用详解

WordPress中的shortcode短代码功能使用详解

WordPress中的shortcode短代码功能使⽤详解WordPress 从 2.5 的版本开始,增加了⼀个 shortcode (短代码) API ,类似于 BBS 上的 BBCode , shortcode 也可以很⽅便的为⽂章或页⾯增加功能,并且 shortcode 的⽐起 BBCode 更加灵活和强⼤。

下⾯ Kayo 为⼤家介绍⼀下 shortcode 。

⼀.shortcode 简介shortcode 可以让开发者通过以函数的形式创建宏内容来⽣成内容,或许这个概念看上去有点模糊,但实际上它是⼀个很简单⽽实⽤的功能,只要会编写基本的 PHP 函数,即可使⽤ shortcode ,下⽂会以实际的例⼦来说明 shortcode 的使⽤⽅法。

⼆.shortcode 形式shortcode ⽀持封闭标签和⾃闭(⾃动封闭)标签,并且⽀持在标签内使⽤参数,⾄于 shortcode 具体是何种形式,这就决定于开发者怎样编写这个 shortcode 了。

[myshortcode]Some Content[/myshortcode] // 封闭标签[myshortcode] // ⾃闭标签[myshortcode title="example"] // 带有⼀个参数的⾃闭标签[myshortcode]<p><a href="#"><span>内容</span></a></p>[/myshortcode] // 标签内可以填写⽂本或 HTML[myshortcode]Content [myshortcodesecond] more content[/myshortcodesecond] // 也可以嵌套使⽤标签三.shortcode 例⼦在使⽤ shortcode 前,⾸先必须在主题的 functions.php ⽂件中定义 shortcode ,例如:function myshortcode_function($atts, $content = null){ // $atts 代表了 shortcode 的各个参数,$content 为标签内的内容extract(shortcode_atts(array( // 使⽤ extract 函数解析标签内的参数"title" => '标题' // 给参数赋默认值,下⾯直接调⽤ $ 加上参数名输出参数值), $atts));// 返回内容return '<div class="myshortcode"><h3>'. $title .'</h3><p>'. $content .'</p></div>';}add_shortcode("msc", "myshortcode_function"); // 注册该 shortcode,以后使⽤ [msc] 标签调⽤该 shortcode把上⾯的代码添加到 functions.php 中,⼀个简单的 shortcode 便创建好了,我们可以通过 [msc][/msc]标签调⽤该 shortcode ,如:[msc title="欢迎"]这是独⽴博客 Kayo's Melody ,欢迎来到本博客[/msc]在⽂章或页⾯内容中输⼊上⾯的调⽤,可以在相应的位置输出⼀段欢迎语句,在 style.css 中定义相应的 CSS ,即可为短代码赋予样式。

get_terms函数

get_terms函数

get_terms函数get_terms函数是WordPress中一个非常有用的函数,它用于获取分类和标签的信息。

在本文中,我将介绍get_terms函数的基本用法以及一些常见的应用场景。

1. 基本用法get_terms函数的基本用法如下:```$terms = get_terms( $args );```其中,$args是一个可选的参数数组,用于指定获取分类和标签的条件。

如果不传递$args参数,则默认获取所有分类和标签。

2. 获取分类要获取分类的信息,可以使用以下代码:```$categories = get_terms( 'category' );```这样,$categories变量将包含所有分类的信息。

可以通过循环遍历的方式来输出每个分类的名称、链接等信息。

3. 获取标签要获取标签的信息,可以使用以下代码:```$tags = get_terms( 'post_tag' );```这样,$tags变量将包含所有标签的信息。

同样地,可以通过循环来输出每个标签的相关信息。

4. 限制数量有时候,我们只希望获取一定数量的分类或标签。

可以通过设置$args数组中的'number'参数来实现。

例如,要获取5个分类,可以使用以下代码:```$categories = get_terms( array('taxonomy' => 'category','number' => 5,) );```5. 按父级分类获取如果希望只获取某个父级分类下的子分类,可以使用'parent'参数。

例如,要获取分类ID为2的父级分类下的子分类,可以使用以下代码:```$categories = get_terms( array('taxonomy' => 'category','child_of' => 2,) );```6. 按分类别名获取有时候,我们可能通过分类的别名来获取分类的信息。

wordpress页面函数-get_pages()

wordpress页面函数-get_pages()

【开源系统】wordpress页面函数-get_pages()作者:胖胖吉/php/get_pages.html【get_pages函数是什么】1.说明get_pages( )函数用于获取博客中已定义页面的列表。

2.用法<?phpget_pages('arguments'); ?>3.示例在下拉列表中显示页面,这是一个包括所有页面的下拉列表的实例。

请注意如何在传递页面编号后,通过调用get_page_link函数来获取页面链接。

<select name=\"page-dropdown\"onchange='document.location.href=this.options[this.selectedIndex].va lue;'><option value=\"\"><?php echo attribute_escape(__('Select page')); ?></option><?php$pages = get_pages();foreach ($pages as $pagg) {$option = '<option value=\"'.get_page_link($pagg->ID).'\">'; $option .= $pagg->post_title;$option .= '</option>';echo $option;}?></select>以文章形式显示目前页面的子页面<?php$pages =get_pages('child_of='.$post->ID.'&sort_column=post_date&sort_order=de sc');$count = 0;foreach($pages as $page){$content = $page->post_content;if(!$content)continue;if($count >= 2)break;$count++;$content = apply_filters('the_content', $content);?><h2><a href=\"<?php echo get_page_link($page->ID) ?>\"><?php echo $page->post_title ?></a></h2><div class=\"entry\"><?php echo $content ?></div><?php}?>3.参数sort_column (字符)按不同方式对页面列表进行排序。

Wordpress Category分类函数、Tags标签函数详解

Wordpress Category分类函数、Tags标签函数详解

Wordpress Category分类函数、Tags标签函数详解对Wordpress进行模板和插件设计,当然少不了要了解Wordpress的函数,就像要用C++、Java少不了API一样。

本篇文章总结了Wordpress Category分类函数和Tags标签函数的使用方法。

目录模板函数集(Category Template Tags)(注意:所有代码的符号均需半角符号)一、获取文章目录链接(Post Category)函数-<?phpthe_category(’arguments’);?>,多参数。

参数说明:①分隔符(seperator),目录之间的分隔符号,可以为文字或字符,默认情况下按照无序列表的形式显示。

例子:<?php the_category('seperator=&bull;');?>②层级参数(parents),如何显示子目录链接,属性值有single和multiple。

例子:<?php the_category('parents=multiple'); ?>二、在RSS中显示文章的发表目录(Post Category in RSS Format)函数-<?php the_category_rss(’arguments’); ?>。

参数说明:①类型(type):Feed显示类型。

例子:<?php the_category_rss('type=rss');?>三、获取页面目录名称函数(Page Category Title)函数-<?phpsingle_cat_title(’prefix’,'display’); ?>,显示或返回当前页面所属目录名称。

参数说明:①前缀(prefix),目录名称前缀,默认值:不显示任何内容。

例子:<?php single_cat_title('&bull;','display');?>②显示目录名称参数(display)。

get_post_format()用法

get_post_format()用法

get_post_format()用法一、概述get_post_format()是一个WordPress函数,用于获取指定文章的格式类型。

它通常用于WordPress主题和插件开发,以便根据文章格式类型显示不同的样式或行为。

二、函数定义```phpfunctionget_post_format($post_ID=null){if(!$post_ID)$post_ID=get_the_ID();returnget_post_format($post_ID);}```此函数接受一个可选参数`$post_ID`,默认为null。

如果没有提供`$post_ID`,则会使用当前文章的ID。

函数返回一个字符串,表示文章的格式类型。

三、用法示例以下是一个使用get_post_format()函数的示例:```php<?php//获取当前文章的格式类型$post_format=get_post_format();//根据格式类型执行不同的操作if('standard'===$post_format){//显示标准格式的文章内容}elseif('aside'===$post_format){//处理侧边栏格式的文章}elseif('quote'===$post_format){//处理引用格式的文章}else{//处理其他格式的文章}>```四、注意事项在使用get_post_format()函数时,需要注意以下几点:1.该函数返回一个字符串,表示文章的格式类型。

你可以根据返回值来决定如何处理或显示文章内容。

2.如果需要自定义文章格式类型的行为或样式,可以考虑使用其他WordPress函数或自定义代码来实现。

3.在WordPress主题和插件开发中,你可以使用get_post_format()函数来扩展或修改默认的格式类型行为。

4.请确保在使用该函数之前,你已经正确安装并启用了WordPress。

wordpress页面函数-get_pages()

wordpress页面函数-get_pages()

【开源系统】wordpress页面函数-get_pages()作者:胖胖吉/php/get_pages.html【get_pages函数是什么】1.说明get_pages( )函数用于获取博客中已定义页面的列表。

2.用法<?phpget_pages('arguments'); ?>3.示例在下拉列表中显示页面,这是一个包括所有页面的下拉列表的实例。

请注意如何在传递页面编号后,通过调用get_page_link函数来获取页面链接。

<select name=\"page-dropdown\"onchange='document.location.href=this.options[this.selectedIndex].va lue;'><option value=\"\"><?php echo attribute_escape(__('Select page')); ?></option><?php$pages = get_pages();foreach ($pages as $pagg) {$option = '<option value=\"'.get_page_link($pagg->ID).'\">'; $option .= $pagg->post_title;$option .= '</option>';echo $option;}?></select>以文章形式显示目前页面的子页面<?php$pages =get_pages('child_of='.$post->ID.'&sort_column=post_date&sort_order=de sc');$count = 0;foreach($pages as $page){$content = $page->post_content;if(!$content)continue;if($count >= 2)break;$count++;$content = apply_filters('the_content', $content);?><h2><a href=\"<?php echo get_page_link($page->ID) ?>\"><?php echo $page->post_title ?></a></h2><div class=\"entry\"><?php echo $content ?></div><?php}?>3.参数sort_column (字符)按不同方式对页面列表进行排序。

WordPress分类函数get categories(获得分类所有信息)

WordPress分类函数get categories(获得分类所有信息)
参数说明
type (字符)post 和 link 其中 link 在新版 3.0 以后已被弃ห้องสมุดไป่ตู้。
child_of (整数)仅显示标注了编号的分类的子类。该参数无默认值。使用该参数时应将 hide_empty 参数设为 false
parent (整数)只显示某个父级分类以及下面的子分类(注:子分类只显示一个层级)。
$option .= $category->cat_name; $option .= ' ('.$category->category_count.')'; $option .= '</option>'; echo $option; } ?> </select>
列表和说明
<?php $args=array(
用 get_categories() 函 数 代 替 wp_list_categories()灵活显示分类列表的例 子
我们在开发 wordpres 主题时一般都是 wplistcategories()显示分类列表,但是有时我们不想 要 class,title 之类的,那么我们可以用 wordpress 中的 get_categories()定制自己的样式, 例如下面的例子就可以生成我们需要的最简单样式,当然你还可以按自己的要求编写
pad_counts (布尔值)通过子类中的项来计算链接或文章。有效值包括 1(true)和 0(false),0 为默认。
number (字符)将要返回的类别数量。
taxonomy (字符)返回一个分类法,这个是 wordpress3.0 版本后新添加的一个参数。返回的值包括 category(默认)和 taxonomy(一些新定义的分类名称)。

wordpress仿站用模板标签大全

wordpress仿站用模板标签大全

WordPress模板基本文件style.css 样式表文件index.php 主页文件single.php 日志单页文件page.php 页面文件archvie.php 分类和日期存档页文件searchform.php 搜索表单文件search.php 搜索页面文件comments.php 留言区域文件(包括留言列表和留言框)404.php 404错误页面header.php 网页头部文件sidebar.php 网页侧边栏文件footer.php 网页底部文件WordPress Header头部PHP代码注: 也就是位于<head>和</head>之间的PHP代码<?php bloginfo(’name’); ?> 网站标题<?php wp_title(); ?> 日志或页面标题<?php bloginfo(’stylesheet_url’); ?> WordPress主题样式表文件style.css的相对地址<?php bloginfo(’pingback_url’); ?> WordPress博客的Pingback地址<?php bloginfo(’template_url’); ?> WordPress主题文件的相对地址<?php bloginfo(’version’); ?> 博客的Wordpress版本<?php bloginfo(’atom_url’); ?> WordPress博客的Atom地址<?php bloginfo(’rss2_url’); ?> WordPress博客的RSS2地址<?php bloginfo(’url’); ?> WordPress博客的绝对地址<?php bloginfo(’name’); ?> WordP ress博客的名称<?php bloginfo(’html_type’); ?> 网站的HTML版本<?php bloginfo(’charset’); ?> 网站的字符编码格式WordPress 主体模板PHP代码<?php the_content(); ?> 日志内容<?php if(have_posts()) : ?> 确认是否有日志<?php while(have_posts()) : the_post(); ?> 如果有,则显示全部日志<?php endwhile; ?> 结束PHP函数”while”<?php endif; ?> 结束PHP函数”if”<?php get_header(); ?> header.php文件的内容<?php get_sidebar(); ?> sidebar.php文件的内容<?php get_footer(); ?> footer.php文件的内容<?php the_time(’m-d-y’) ?> 显示格式为”02-19-08″的日期<?php comments_popup_link(); ?> 显示一篇日志的留言链接<?php the_title(); ?> 显示一篇日志或页面的标题<?php the_permalink() ?> 显示一篇日志或页面的永久链接/URL地址<?php the_category(’, ‘) ?> 显示一篇日志或页面的所属分类<?php the_author(); ?> 显示一篇日志或页面的作者<?php the_ID(); ?> 显示一篇日志或页面的ID<?php edit_post_link(); ?> 显示一篇日志或页面的编辑链接<?php get_links_list(); ?> 显示Blogroll中的链接<?php comments_template(); ?> comments.php文件的内容<?php wp_list_pages(); ?> 显示一份博客的页面列表<?php wp_list_cats(); ?> 显示一份博客的分类列表<?php next_post_link(’ %link ‘) ?> 下一篇日志的URL地址<?php previous_post_link(’%link’) ?> 上一篇日志的URL地址<?php get_calendar(); ?> 调用日历<?php wp_get_archives() ?> 显示一份博客的日期存档列表<?php posts_nav_link(); ?> 显示较新日志链接(上一页)和较旧日志链接(下一页)<?php bloginfo(’description’); ?> 显示博客的描述信息其它的一些Wordpress模板代码/%postname%/ 显示博客的自定义永久链接<?php the_search_query(); ?> 搜索表单的值<?php _e(’Message’); ?> 打印输出信息<?php wp_register(); ?> 显示注册链接<?php wp_loginout(); ?> 显示登入/登出链接<!–next page–> 在日志或页面中插入分页<!–more–> 截断日志<?php wp_meta(); ?> 显示管理员的相关控制信息<?php timer_stop(1); ?> 显示载入页面的时间<?php echo get_num_queries(); ?> 显示载入页面查询1. wordpress调用最新文章WordPress最新文章的调用可以使用一行很简单的模板标签wp_get_archvies来实现. 代码如下:<?php get_archives('postbypost', 10); ?> (显示10篇最新更新文章)或者<?php wp_get_archives(‘type=postbypost&limit=20&format=custom’); ?>后面这个代码显示你博客中最新的20篇文章,其中format=custom这里主要用来自定义这份文章列表的显示样式。

WordPress单页面上一页下一页实现方法

WordPress单页面上一页下一页实现方法

WordPress单页面上一页下一页实现方法WordPress单页面上一页下一页实现方法WordPress的文章页页有实现上一篇下一篇的功能函数,不过我们想在单页page.php里面实现上一页下一页的功能,previous_post_link()和next_post_link() 函数还不能完全满足我的需要,所以就自己写函数实现。

页面有分级功能,需求是按menu order 排序的子级页面之间有上一篇、下一篇链接,如:Themes(父级页面)---- zBench(子级页面1)---- zBorder(子级页面2)---- zSofa(子级页面3)如果当前页面是zBorder,那么就要上一篇链接是zBench 的.,下一篇链接是 zSofa 的。

把下面函数代码放入functions.php(注:函数随手写的,可能不够精简)/*** get subpage previous/next page link by zwwooooo*/function subpage_nav_link($prevText='', $nextT ext='') {global $post;if ( !$post->post_parent ) return null; //如果不是子页面返回Null$args = array('sort_order' => 'ASC','sort_column' => 'menu_order','child_of' => $post->post_parent,'post_type' => 'page');$pages = get_pages($args);$num = count($pages);$i = 0;$index = -1;foreach ($pages as $page) {if ($page->ID == $post->ID) {$index = $i;break;}++$i;}if ($i == 0) {$prev = '';$next = $pages[$index+1];} elseif ($i == $num-1) {$prev = $pages[$index-1];$next = '';} else {$prev = $pages[$index-1];$next = $pages[$index+1];}if ($prev) {if ($prevText) {if ( substr_count($prevText, '%title') > 0 ) {$explode = explode('%title', $prevText);$prevText = $explode[0] . get_the_title($prev->ID) . $explode[1];}} else {$prevText = get_the_title($prev->ID);}$prevlink = '<a class="previous-page-link" href="' . get_page_link($prev->ID). '">' . $prevText . '</a>';}if ($next) {if ($nextText) {if ( substr_count($nextText, '%title') > 0 ) {$explode = explode('%title', $nextText);$nextText = $explode[0] . get_the_title($next->ID) . $explode[1];}} else {$nextText = get_the_title($next->ID);}$nextlink = '<a class="next-page-link" href="' . get_page_link($next->ID). '">' . $nextText . '</a>';}return array($prevlink, $nextlink);}[函数]subpage_nav_link($prevText, $nextText)[参数]$prevText: 为前一篇文章链接文字,为空时默认是页面标题$nextText: 为下一篇文章链接文字,为空时默认是页面标题;例如:一般的主题是在 page.php 的 loop 循环里面(不知道就在the_content(); 下面吧)插入调用代码<?phpif ( function_exists('subpage_nav_link') ) {if ( $subpage_nav_link = subpage_nav_link() ) {echo $subpage_nav_link[0]; //上一篇(页面)链接echo $subpage_nav_link[1]; //下一篇(页面)链接}}>注:可以用 if (!$subpage_nav_link[0]) 来判断有没有上一篇,同样 if (!$subpage_nav_link[1]) 来判断有没有下一篇。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

完整的WordPress函数大全
在修改和制作Wordpress主题时经常为不知道内置函数而苦恼,而wordpress官方的文档看起来又不是那么方便。

所搜集并且整理了一下放这,以备后用。

判断页面函数
is_home() : 是否为主页
is_single() : 是否为内容页(P ost)
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页是否以多页显示
Header部分常用到的PHP函数
<?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函数及命令
<?php get_header(); ?> : 调用Header模板
<?php get_sidebar(); ?> : 调用Sidebar模板
<?php get_footer(); ?> : 调用Footer模板
<?php the_content(); ?> : 显示内容(Post/Page)
<?php if(have_posts()) : ?> : 检查是否存在Post/Page
<?php while(have_posts()) : the_post(); ?> : 如果存在P ost/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() ?> : 内容页(P ost/Page) Url
<?php the_category(‟, …) ?> : 特定内容页(P ost/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(TEMPLATEP ATH . …/文件名‟); ?> : 嵌入其他文件,可为定制的模板或其他类型文件
其他函数
<?php _e(‟Message‟); ?> : 输出相应信息
<?php wp_register(); ?> : 显示注册链接
<?php wp_loginout(); ?> : 显示登录/注销链接
<!–next page–> : 将当前内容分页
<!–more–> : 将当前内容截断,以不在主页/目录页显示全部内容
<?php timer_stop(1); ?> : 网页加载时间(秒)
<?php echo get_num_queries(); ?> : 网页加载查询量。

相关文档
最新文档