WordPress官方函数索引(英文版)

The files of WordPress define many useful PHP functions. Some of the functions, known as Template Tags, are defined especially for use in WordPress Themes. There are also some functions related to actions and filters (the Plugin API), which are therefore used primarily for developing Plugins. The rest are used to create the core WordPress functionality.

Many of the core WordPress functions are useful to Plugin and Theme developers. So, this article lists most of the core functions, excluding Template Tags. At the bottom of the page, there is a section listing other resources for finding information about WordPress functions. In addition to this information, the WordPress phpdoc site details all the WordPress functions by version since 2.6.1.

You can help make this page more complete!

Here are some things you can do to help:

  • Add documentation to un-documented functions, by creating sub-pages or at least by adding short comments in the lists below. If you create a subpage for a function, please include information and examples of usage of that function, if possible, per the examples found in Template Tags.
  • List more functions here, following the category structure.
  • Correct errors by moving functions to better categories where appropriate, and of course fixing typos. Note: that it is OK for a function to appear in more than one category.

Read Contributing to WordPress to find out more about how you can contribute to the effort!

Functions by category

Post, Custom Post Type, Page, Attachment and Bookmarks Functions

Posts

  • get_adjacent_post
  • get_boundary_post
  • get_children
  • get_extended
  • get_next_post
  • get_next_posts_link
  • get_permalink
  • get_the_excerpt
  • get_the_post_thumbnail
  • get_post
  • get_post_ancestors
  • get_post_mime_type
  • get_post_status
  • get_post_format
  • get_edit_post_link
  • get_previous_post
  • previous_posts_link
  • get_posts
  • is_post (deprecated)
  • is_single
  • is_sticky
  • the_ID
  • the_date
  • wp_get_recent_posts
  • wp_get_single_post

Custom Post Type

  • register_post_type
  • is_post_type_archive
  • post_type_archive_title
  • add_post_type_support
  • remove_post_type_support
  • post_type_supports
  • set_post_type
  • post_type_exists
  • get_post_type
  • get_post_types
  • get_post_type_archive_link
  • get_post_type_object
  • get_post_type_capabilities
  • get_post_type_labels
  • is_post_type_hierarchical

Post insertion/removal

  • wp_delete_post
  • wp_insert_post
  • wp_publish_post
  • wp_update_post

Pages

  • get_all_page_ids
  • get_ancestors
  • get_page
  • get_page_link
  • get_page_by_path
  • get_page_by_title
  • get_page_children
  • get_page_hierarchy
  • get_page_uri
  • get_pages
  • is_page
  • page_uri_index
  • wp_list_pages
  • wp_page_menu

Custom Fields (postmeta)

  • add_post_meta
  • delete_post_meta
  • get_post_custom
  • get_post_custom_keys
  • get_post_custom_values
  • get_post_meta
  • update_post_meta

Attachments

  • get_attached_file
  • is_attachment
  • is_local_attachment
  • update_attached_file
  • wp_attachment_is_image
  • wp_insert_attachment
  • wp_delete_attachment
  • wp_get_attachment_image
  • wp_get_attachment_link
  • wp_get_attachment_image_src
  • wp_get_attachment_metadata
  • wp_get_attachment_thumb_file
  • wp_get_attachment_thumb_url
  • wp_get_attachment_url
  • wp_check_for_changed_slugs
  • wp_count_posts
  • wp_mime_type_icon
  • wp_generate_attachment_metadata
  • wp_update_attachment_metadata

Bookmarks

  • get_bookmark
  • get_bookmarks
  • wp_list_bookmarks

Terms

  • wp_get_post_categories
  • wp_set_post_categories
  • wp_get_post_tags
  • wp_set_post_tags
  • wp_get_post_terms
  • wp_set_post_terms


Others

  • add_meta_box
  • remove_meta_box
  • get_the_ID
  • get_the_author
  • get_the_content
  • get_the_title
  • wp_trim_excerpt

Category, Tag and Taxonomy Functions

Categories

  • cat_is_ancestor_of
  • get_all_category_ids
  • get_ancestors
  • get_cat_ID
  • get_cat_name
  • get_categories
  • get_category
  • get_category_by_path
  • get_category_by_slug
  • get_the_category_by_ID
  • get_category_link
  • get_category_parents
  • get_the_category
  • in_category
  • is_category
  • the_category
  • wp_category_checklist
  • wp_list_categories

Category Creation

  • wp_create_category
  • wp_delete_category
  • wp_insert_category

Tags

  • get_tag
  • get_tag_link
  • get_tags
  • get_the_tag_list
  • get_the_tags
  • is_tag
  • the_tags

Taxonomy

  • get_taxonomies
  • get_term
  • get_the_term_list
  • get_term_by
  • the_terms
  • get_the_terms
  • get_term_children
  • get_term_link
  • get_terms
  • is_taxonomy (deprecated)
  • is_taxonomy_hierarchical
  • is_term (deprecated)
  • taxonomy_exists
  • term_exists
  • register_taxonomy
  • register_taxonomy_for_object_type
  • wp_get_object_terms
  • wp_set_object_terms
  • wp_insert_term
  • wp_update_term
  • wp_delete_term
  • wp_terms_checklist

User and Author Functions

Admins, Roles and Capabilities

  • add_cap
  • add_role
  • author_can
  • current_user_can
  • current_user_can_for_blog
  • get_role
  • get_super_admins
  • is_super_admin
  • map_meta_cap
  • remove_cap
  • remove_role
  • user_can

Users and Authors

  • auth_redirect
  • count_users
  • count_user_posts
  • count_many_users_posts
  • email_exists
  • get_currentuserinfo
  • get_current_user_id
  • get_profile
  • get_userdata
  • get_userdatabylogin
  • get_usernumposts
  • get_users
  • get_users_of_blog
  • set_current_user
  • user_pass_ok
  • username_exists
  • validate_username
  • wp_get_current_user
  • wp_set_current_user
  • get_author_posts_url

User meta

  • add_user_meta
  • delete_user_meta
  • get_user_meta
  • update_user_meta

User insertion/removal

  • wp_create_user
  • wp_delete_user
  • wp_insert_user
  • wp_update_user

Login / Logout

  • is_user_logged_in
  • wp_signon
  • wp_logout

Feed Functions

  • bloginfo_rss
  • comment_author_rss
  • comment_link
  • comment_text_rss
  • do_feed
  • do_feed_atom
  • do_feed_rdf
  • do_feed_rss
  • do_feed_rss2
  • fetch_feed
  • fetch_rss (deprecated)
  • get_author_feed_link
  • get_bloginfo_rss
  • get_category_feed_link
  • get_comment_link
  • get_comment_author_rss
  • get_post_comments_feed_link
  • get_rss (deprecated)
  • get_search_comments_feed_link
  • get_search_feed_link
  • get_the_category_rss
  • get_the_title_rss
  • permalink_single_rss
  • post_comments_feed_link
  • rss_enclosure
  • the_title_rss
  • the_category_rss
  • the_content_rss
  • the_excerpt_rss
  • wp_rss (deprecated)

Comment, Ping, and Trackback Functions

  • add_ping
  • add_comment_meta
  • check_comment
  • comment_text
  • comment_form
  • comments_number
  • discover_pingback_server_uri
  • delete_comment_meta
  • do_all_pings
  • do_enclose
  • do_trackbacks
  • generic_ping
  • get_approved_comments
  • get_avatar
  • get_comment
  • get_comment_text
  • get_comment_meta
  • get_comments
  • wp_list_comments
  • get_enclosed
  • get_lastcommentmodified
  • get_pung
  • get_to_ping
  • have_comments
  • is_trackback
  • pingback
  • privacy_ping_filter
  • sanitize_comment_cookies
  • trackback
  • trackback_url
  • trackback_url_list
  • update_comment_meta
  • weblog_ping
  • wp_allow_comment
  • wp_count_comments
  • wp_delete_comment
  • wp_filter_comment
  • wp_get_comment_status
  • wp_get_current_commenter
  • wp_insert_comment
  • wp_new_comment
  • wp_set_comment_status
  • wp_throttle_comment_flood
  • wp_update_comment
  • wp_update_comment_count

Comments Loop

  • comment_class
  • comment_ID
  • comment_author
  • comment_date
  • comment_time

Comments Pagination

  • paginate_comments_links
  • previous_comments_link
  • next_comments_link

Action, Filter, and Plugin Functions

Filters

  • has_filter
  • add_filter
  • apply_filters
  • current_filter
  • merge_filters
  • remove_filter
  • remove_all_filters

Actions

  • has_action
  • add_action
  • do_action
  • do_action_ref_array
  • did_action
  • remove_action
  • remove_all_actions

Plugins

  • plugin_basename
  • plugins_url
  • register_activation_hook
  • register_deactivation_hook
  • register_setting
  • settings_fields
  • unregister_setting
  • menu_page_url

Shortcodes

  • add_shortcode
  • do_shortcode
  • do_shortcode_tag
  • get_shortcode_regex
  • remove_shortcode
  • remove_all_shortcodes
  • shortcode_atts
  • shortcode_parse_atts
  • strip_shortcodes

Theme-Related Functions

Include functions

  • comments_template
  • get_footer
  • get_header
  • get_sidebar
  • get_search_form

Other functions

  • add_custom_background
  • add_custom_image_header
  • add_theme_support
  • body_class
  • current_theme_supports
  • dynamic_sidebar
  • get_404_template
  • get_archive_template
  • get_attachment_template
  • get_author_template
  • get_category_template|get_category_template
  • get_comments_popup_template
  • get_current_theme
  • get_date_template
  • get_header_image
  • get_header_textcolor
  • get_home_template
  • get_locale_stylesheet_uri
  • get_page_template
  • get_paged_template
  • get_query_template
  • get_search_template
  • get_single_template
  • get_stylesheet
  • get_stylesheet_directory
  • get_stylesheet_directory_uri
  • get_stylesheet_uri
  • get_tag_template
  • get_taxonomy_template
  • get_template
  • get_template_directory
  • get_template_directory_uri
  • get_template_part
  • get_theme
  • get_theme_data
  • get_theme_support
  • get_theme_mod
  • get_theme_root
  • get_theme_root_uri
  • get_themes
  • header_image
  • header_textcolor
  • is_child_theme
  • load_template
  • locale_stylesheet
  • locate_template
  • post_class
  • preview_theme
  • preview_theme_ob_filter
  • preview_theme_ob_filter_callback
  • register_nav_menu
  • register_nav_menus
  • register_sidebar
  • register_sidebars
  • register_theme_directory
  • remove_theme_mod
  • remove_theme_mods
  • require_if_theme_supports
  • search_theme_directories
  • set_theme_mod
  • switch_theme
  • validate_current_theme
  • unregister_nav_menu
  • wp_get_archives
  • wp_get_nav_menu_items
  • wp_nav_menu
  • wp_page_menu
  • wp_title

Formatting Functions

  • add_magic_quotes
  • addslashes_gpc
  • antispambot
  • attribute_escape
  • backslashit
  • balanceTags
  • clean_pre
  • clean_url
  • convert_chars
  • convert_smilies
  • ent2ncr
  • esc_attr
  • esc_html
  • esc_js
  • esc_textarea
  • esc_url
  • force_balance_tags
  • format_to_edit
  • format_to_post
  • funky_javascript_fix
  • htmlentities2
  • is_email
  • js_escape (deprecated)
  • make_clickable
  • popuplinks
  • remove_accents
  • sanitize_email
  • sanitize_file_name
  • sanitize_user
  • sanitize_title
  • sanitize_title_with_dashes
  • seems_utf8
  • stripslashes_deep
  • trailingslashit
  • untrailingslashit
  • url_shorten
  • utf8_uri_encode
  • wpautop
  • wptexturize
  • wp_filter_kses
  • wp_filter_post_kses
  • wp_filter_nohtml_kses
  • wp_iso_descrambler
  • wp_kses
  • wp_kses_array_lc
  • wp_kses_attr
  • wp_kses_bad_protocol
  • wp_kses_bad_protocol_once
  • wp_kses_bad_protocol_once2
  • wp_kses_check_attr_val
  • wp_kses_decode_entities
  • wp_kses_hair
  • wp_kses_hook
  • wp_kses_html_error
  • wp_kses_js_entities
  • wp_kses_no_null
  • wp_kses_normalize_entities
  • wp_kses_normalize_entities2
  • wp_kses_split
  • wp_kses_split2
  • wp_kses_stripslashes
  • wp_kses_version
  • wp_make_link_relative
  • wp_rel_nofollow
  • wp_richedit_pre
  • wp_specialchars
  • wp_trim_words
  • zeroise

Miscellaneous Functions

Time/Date Functions

  • current_time
  • date_i18n
  • get_calendar
  • get_date_from_gmt
  • get_lastpostdate
  • get_lastpostmodified
  • get_day_link
  • get_gmt_from_date
  • get_month_link
  • get_the_time
  • get_weekstartend
  • get_year_link
  • human_time_diff
  • is_new_day
  • iso8601_timezone_to_offset
  • iso8601_to_datetime
  • mysql2date

Serialization

  • is_serialized
  • is_serialized_string
  • maybe_serialize
  • maybe_unserialize

Options

  • add_option
  • delete_option
  • form_option
  • get_alloptions
  • get_site_option
  • get_site_url
  • get_user_option
  • get_option
  • update_option
  • update_user_option

Admin Menu Functions

  • add_menu_page
  • remove_menu_page
  • add_submenu_page
  • remove_submenu_page
  • add_object_page
  • add_utility_page

Toolbar Functions

  • add_node
  • remove_node
  • add_group
  • get_node
  • get_nodes

Form Helpers

  • checked
  • disabled
  • selected

Nonces and Referers (Security)

  • check_admin_referer
  • check_ajax_referer
  • wp_create_nonce
  • wp_explain_nonce
  • wp_get_original_referer
  • wp_get_referer
  • wp_nonce_ays
  • wp_nonce_field
  • wp_nonce_url
  • wp_original_referer_field
  • wp_referer_field
  • wp_verify_nonce

XMLRPC

  • xmlrpc_getpostcategory
  • xmlrpc_getposttitle
  • xmlrpc_removepostdata
  • user_pass_ok

Localization

  • __
  • _e
  • _ngettext
  • _n
  • _x
  • esc_attr__
  • esc_attr_e
  • get_locale
  • load_default_textdomain
  • load_plugin_textdomain
  • load_textdomain
  • load_theme_textdomain

Cron (Scheduling)

  • spawn_cron
  • wp_clear_scheduled_hook
  • wp_cron
  • wp_get_schedule
  • wp_get_schedules
  • wp_next_scheduled
  • wp_reschedule_event
  • wp_schedule_event
  • wp_schedule_single_event
  • wp_unschedule_event

Conditional Tags Index

  • comments_open
  • has_nav_menu
  • has_tag
  • in_category
  • is_404
  • is_admin
  • is_archive
  • is_attachment
  • is_author
  • is_category
  • is_comments_popup
  • is_date
  • is_day
  • is_feed
  • is_front_page
  • is_home
  • is_month
  • is_page
  • is_page_template
  • is_paged
  • is_preview
  • is_search
  • is_single
  • is_singular
  • is_sticky
  • is_tag
  • is_tax
  • is_time
  • is_trackback
  • is_year
  • pings_open

Miscellaneous

  • add_query_arg
  • admin_url
  • bool_from_yn
  • cache_javascript_headers
  • content_url
  • do_robots
  • get_bloginfo
  • get_num_queries
  • get_query_var
  • home_url
  • includes_url
  • is_blog_installed
  • is_main_site
  • is_main_query
  • is_ssl
  • log_app
  • make_url_footnote (deprecated)
  • nocache_headers
  • remove_query_arg
  • site_url
  • status_header
  • wp
  • wp_check_filetype
  • wp_clearcookie
  • wp_die
  • wp_footer
  • wp_get_cookie_login
  • wp_get_http_headers
  • wp_hash
  • wp_head
  • wp_mail
  • wp_mkdir_p
  • wp_new_user_notification
  • wp_notify_moderator
  • wp_notify_postauthor
  • wp_parse_args
  • wp_redirect
  • wp_reset_postdata
  • wp_reset_query
  • wp_remote_fopen
  • wp_salt
  • wp_set_auth_cookie
  • wp_upload_bits
  • wp_upload_dir

你可能感兴趣的:(WordPress)