Skip to content

Instantly share code, notes, and snippets.

@AnadarProSvcs
Last active January 20, 2024 14:28
Show Gist options
  • Save AnadarProSvcs/659ee1605d35edea3e2a97fd81ec6b71 to your computer and use it in GitHub Desktop.
Save AnadarProSvcs/659ee1605d35edea3e2a97fd81ec6b71 to your computer and use it in GitHub Desktop.
WP_POST Object in WordPress - common functions and properties.

WordPress WP_Post Object Reference

Properties of WP_Post

  • ID: Unique identifier for the post.
  • post_author: ID of the post's author.
  • post_date: Date and time of post publication.
  • post_date_gmt: Date and time of post publication in GMT.
  • post_content: Full content of the post.
  • post_title: Title of the post.
  • post_excerpt: Excerpt or summary of the post.
  • post_status: Status of the post (e.g., 'publish', 'draft').
  • comment_status: Whether comments are open or closed.
  • ping_status: Whether pings and trackbacks are allowed.
  • post_password: Password for protected posts.
  • post_name: Slug of the post.
  • to_ping: URLs to ping.
  • pinged: URLs that have been pinged.
  • post_modified: Date and time of last modification.
  • post_modified_gmt: Date and time of last modification in GMT.
  • post_content_filtered: Modified post content (used by plugins).
  • post_parent: ID of the parent post.
  • guid: Global Unique Identifier of the post.
  • menu_order: Order of the post in menus.
  • post_type: Type of the post (e.g., 'post', 'page').
  • post_mime_type: MIME type (for attachments).
  • comment_count: Number of comments on the post.

WordPress Post Functions

  • get_post(): Retrieves a post by ID or current post.
  • the_post(): Iterates post index in the loop.
  • have_posts(): Checks if the current query has posts.
  • the_title: Displays the current post title.
  • get_the_title(): Retrieves the current post title.
  • the_content(): Displays the content of the post.
  • get_the_content(): Retrieves the content of the post.
  • the_excerpt(): Displays the post excerpt.
  • get_the_excerpt(): Retrieves the post excerpt.
  • the_permalink(): Displays the URL of the post.
  • get_permalink(): Retrieves the URL of the post.
  • get_the_ID(): Retrieves the ID of the current item in the Loop.
  • wp_insert_post(): Inserts a new or updates an existing post.
  • wp_update_post(): Updates an existing post.
  • wp_delete_post(): Deletes a post by ID.
  • get_post_field(): Returns data from a post field.
  • get_post_meta(): Retrieves a post meta field.
  • add_post_meta(): Adds a meta field to a post.
  • update_post_meta(): Updates a post meta field.
  • delete_post_meta(): Deletes a post meta field.
  • set_post_thumbnail(): Sets the thumbnail for a post.
  • get_the_post_thumbnail(): Retrieves the post thumbnail.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment