Show Menu
Cheatography

WordPress v5 Functions Cheat Sheet (DRAFT) by

WordPress functions from the official core API documentation.

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Post and Page Functions

Posts
Gets previous or next post.
get_adjacent_post ( b $in_sa­me_­term, a|s $exclu­ded­_terms, b $previous, s $taxonomy )
Gets first or last post.
get_boundary_post ( b $in_sa­me_­term, a|s $exclu­ded­_terms, b $start, s $taxonomy )
Gets children of post.
get_children ( m $args, c $output )
Gets extended content from string.
get_extended ( s $post_­content )
Gets next post.
get_next_post ( b $in_sa­me_­term, a|s $exclu­ded­_terms, s $taxonomy )
Gets next post link.
get_next_posts_link ( s $label, i $max_page )
Displays next post link.
next_posts_link ( s $label, i $max_page )
Gets post permalink.
get_permalink ( i|WP_Post $post, b $leavename )
Prints post permalink.
the_permalink ( i|WP_Post $post )
Gets post excerpt.
get_the_excerpt ( i|WP_Post $post )
Displays post excerpt.
Gets post thumbnail.
get_the_post_thumbnail ( i|WP_Post $post, s|a $size, s|a $attr )
Gets a post.
get_post ( i|WP_Post $post, c $output, s $filter )
Gets post field.
get_post_field ( s $field, i|WP_Post $post, s $context )
Gets parents of post.
get_post_ancestors ( i|WP_Post $post )
Gets post mime type.
get_post_mime_type ( i|WP_Post $post )
Gets post status.
get_post_status ( i|WP_Post $post )
Gets post format.
get_post_format ( i|object $post )
Sets post format.
set_post_format ( i|object $post, s $format )
Gets post edit link.
get_edit_post_link ( i|WP_Post $post, s $context )
Gets post delete link.
get_delete_post_link ( i|WP_Post $post, s $depre­cated, b $force­_delete )
Gets previous post.
get_previous_post ( b $in_sa­me_­term, a|s $exclu­ded­_terms, s $taxonomy )
Gets previous post link.
Displays previous post link.
previous_posts_link ( s $label )
Gets posts.
get_posts ( a $args )
Does query have results remaining?
Is this a single post?
is_single ( i|s|a $post )
Is post flagged as sticky?
is_sticky ( i $post_id )
Gets ID of current loop item.
Displays ID of current loop item.
the_ID ( )
Iterates the loop index.
Gets recent posts.
wp_get_recent_posts ( a $args, c $output )
Does post have an image?
has_post_thumbnail ( i|WP_Post $post )
Does post have an excerpt?
has_excerpt ( i|WP_Post $post )
Does post have the specified format?
has_post_format ( s|a $format, i|WP_Post $post )
Custom Posts
Add a post status.
register_post_status ( s $post_­status, a|s $args )
Add a post type.
register_post_type ( s $post_­type, a|s $args )
Is this a post type archive?
is_post_type_archive ( s|a $post_­types )
Gets/d­isplays post type archive title.
post_type_archive_title ( s $prefix, b $display )
Add feature support to post type.
add_post_type_support ( s $post_­type, s|a $feature )
Remove feature support from post type.
remove_post_type_support ( s $post_­type, s|a $feature )
Does post type support a feature?
post_type_supports ( s $post_­type, s|a $feature )
Sets post type of post.
set_post_type ( i $post_id, s $post_type )
Does post type exist?
post_type_exists ( s $post_type )
Gets attachment image.
wp_get_attachment_image ( i $attac­h_id, s|a $size, b $icon, s|a $attr )
Gets attachment link.
wp_get_attachment_link ( i|WP_Post $post, s|a $size, b $perma­link, b $icon, s $text, a|s $attr )
Gets attachment mime type icon.
wp_get_attachment_image_src ( i $attac­h_id, s|a $size, b $icon )
Gets attachment metadata.
wp_get_attachment_metadata ( i $attac­h_id, b $unfil­tered )
Gets attachment thumbnail.
Gets attachment thumbnail URL.
Gets attachment URL.
wp_get_attachment_url ( i $attach_id )
Did page edit change slug?
wp_check_for_changed_slugs ( i $post_id, WP_Post $post, WP_Post $post_­before )
Gets count of posts with post type.
wp_count_posts ( s $post_­type, s $permi­ssion )
Gets mime types and file extens­ions.
Gets mime type icon.
wp_mime_type_icon ( s|i $mime )
Gets attachment thumbnail metadata.
wp_generate_attachment_metadata ( i $attac­h_id, s $file )
Converts attachment to JS-ready format.
wp_prepare_attachment_for_js ( m $attac­hment )
Sets attachment metadata.
wp_update_attachment_metadata ( i $attac­h_id, array $data )
Bookmarks
Gets a bookmark.
get_bookmark ( i|stdClass $bookmark, c $output, s $filter )
Gets bookmarks.
get_bookmarks ( s|a $args )
Gets/d­isplays all bookmarks.
wp_list_bookmarks ( s|a $args )
Other Post-R­elated Functi­ons
Adds meta box to screen.
add_meta_box ( s $id, s $title, f $callback, s|a|WP­_Screen $screen, s $context, s $priority, a $callb­ack­_args )
Removes meta box from screen.
remove_meta_box ( s $id, s|a|WP­_Screen $screen, s $context )
Gets loop item author.
Displays loop item author.
Gets posts by loop item author.
Gets loop item content.
get_the_content ( s $more_­lin­k_text, b $strip­_teaser )
Displays loop item content.
the_content ( s $more_­lin­k_text, b $strip­_teaser )
Gets post title.
get_the_title ( i|WP_Post $post )
Displays loop item title.
the_title ( s $before, s $after, b $echo )
Sanitizes loop item title.
the_title_attribute ( s|a $args )
Gets excerpt of proper length.
wp_trim_excerpt ( s $text )
Gets a post revision.
wp_get_post_revision ( i|WP_Post $post, c $output, s $filter )
Gets post revisions.
wp_get_post_revisions ( i|WP_Post $post, a $args )
Is post a revision?
wp_is_post_revision ( i|WP_Post $post )
Gets paginated link for archive.
paginate_links ( s|a $args )
 

Category, Tag and Taxonomy Functions

Posts
Gets post catego­ries.
wp_get_post_categories ( i $post_id, a $args )
Sets post catego­ries.
wp_set_post_categories ( i $post_id, a|i $post_­cats, b $append )
           

Help Us Go Positive!

We offset our carbon usage with Ecologi. Click the link below to help us!

We offset our carbon footprint via Ecologi