{"id":3346,"date":"2014-07-08T15:40:34","date_gmt":"2014-07-08T15:40:34","guid":{"rendered":"https:\/\/www.inmotionhosting.com\/support\/2014\/07\/08\/wordpress-wp-post-objects\/"},"modified":"2021-08-16T22:58:33","modified_gmt":"2021-08-17T02:58:33","slug":"wordpress-wp-post-objects","status":"publish","type":"post","link":"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/wordpress-wp-post-objects\/","title":{"rendered":"WordPress WP_Post objects"},"content":{"rendered":"\n<p>When using WordPress functions such as <a href=\"\/support\/edu\/wordpress\/get-post-wordpress-function\/\"><em>get_post()<\/em><\/a>, the information will be stored within WP_Post objects. In this article, we will show you what is stored within those WP_Post objects, as well as how to access them.<\/p>\n\n\n\n<p>If you would like more information on creating WordPress plugins, see our tutorial series on <a href=\"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/plugins\/create-a-wordpress-plugin\/\"  >creating your first WordPress plugin<\/a>.<\/p>\n\n\n\n<p class=\"alert alert-warning\"><strong><em>Looking for a server for your development projects?&nbsp; InMotion provides scalable <\/em><\/strong><a href=\"https:\/\/www.inmotionhosting.com\/wordpress-hosting\"><strong><em>WordPress Hosting<\/em><\/strong><\/a><strong><em> solutions that can fit your budget and performance needs.<\/em><\/strong><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Variables stored within WP_Post objects<\/h2>\n\n\n\n<p><strong>ID<\/strong>: This variable stores the post&#8217;s ID.<\/p>\n\n\n\n<p><strong>post_author<\/strong>: This variable stores the post author&#8217;s numeric user ID.<\/p>\n\n\n\n<p><strong>post_type<\/strong>: This variable contains the post&#8217;s type.<\/p>\n\n\n\n<p><strong>post_title<\/strong>: This variable stores the title of the post.<\/p>\n\n\n\n<p><strong>post_date<\/strong>: This variable displays the date and time of the post.<\/p>\n\n\n\n<p><strong>post_date_gmt<\/strong>: This variable displays the same content as post_date, but in GMT.<\/p>\n\n\n\n<p><strong>post_content<\/strong>: This variable stores the content of the post.<\/p>\n\n\n\n<p><strong>post_excerpt<\/strong>: This variable stores the user-defined excerpt of the post.<\/p>\n\n\n\n<p><strong>post_status<\/strong>: This variable stores the post&#8217;s current status.<\/p>\n\n\n\n<p><strong>comment_status<\/strong>: This variable stores information on whether the comments are open or closed on the post.<\/p>\n\n\n\n<p><strong>ping_status<\/strong>: This variable stores information on whether the post is open or closed for pingbacks.<\/p>\n\n\n\n<p><strong>post_password<\/strong>: This variable stores the post&#8217;s password. It will return empty if the post does not have a password.<\/p>\n\n\n\n<p><strong>post_parent<\/strong>: If the post has a parent post, this variable will return the ID of the parent post.<\/p>\n\n\n\n<p><strong>post_modified<\/strong>: This variable stores the date and time that the post was last modified.<\/p>\n\n\n\n<p><strong>post_modified_gmt<\/strong>: This variable stores the last modified date and time in GMT.<\/p>\n\n\n\n<p><strong>comment_count<\/strong>: This variable stores the number of comments that have been left on the post.<\/p>\n\n\n\n<p><strong>menu_order<\/strong>: If a menu order is defined for the post, it will display it in this variable.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Getting data from WP_Post objects<\/h2>\n\n\n\n<p>Getting information from WP_Post objects is quite simple:<\/p>\n\n\n\n<p class=\"code_block\">&lt;?php<br>$example = get_post();<br>echo $example-&gt;post_title;<br>?&gt;<\/p>\n\n\n\n<p>In this example, we are storing information from the <em>get_post()<\/em> function to the <em>$example<\/em> variable. As the <em>get_post()<\/em> function stores data using WP_Post objects, the <em>$example<\/em> variable now contains WP_Post objects.<\/p>\n\n\n\n<p>Next, we simply call the desired WP_Post object from inside the <em>$example<\/em> variable and display it using the <em>echo<\/em> PHP command.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When using WordPress functions such as get_post(), the information will be stored within WP_Post objects. In this article, we will show you what is stored within those WP_Post objects, as well as how to access them. If you would like more information on creating WordPress plugins, see our tutorial series on creating your first WordPress<a class=\"moretag\" href=\"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/wordpress-wp-post-objects\/\"> Read More ><\/a><\/p>\n","protected":false},"author":12,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4325,56],"tags":[],"class_list":["post-3346","post","type-post","status-publish","format-standard","hentry","category-wordpress-hosting","category-wordpress"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>WordPress WP_Post objects | InMotion Hosting<\/title>\n<meta name=\"description\" content=\"In this article, we will show you what information is stored in WP_Post objects and how to access that information.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/wordpress-wp-post-objects\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"WordPress WP_Post objects | InMotion Hosting\" \/>\n<meta property=\"og:description\" content=\"In this article, we will show you what information is stored in WP_Post objects and how to access that information.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/wordpress-wp-post-objects\/\" \/>\n<meta property=\"og:site_name\" content=\"InMotion Hosting Support Center\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/inmotionhosting\/\" \/>\n<meta property=\"article:published_time\" content=\"2014-07-08T15:40:34+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-08-17T02:58:33+00:00\" \/>\n<meta name=\"author\" content=\"Jeff Matson\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@InMotionHosting\" \/>\n<meta name=\"twitter:site\" content=\"@InMotionHosting\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jeff Matson\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/wordpress-wp-post-objects\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/wordpress-wp-post-objects\/\"},\"author\":{\"name\":\"Jeff Matson\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/83776252b196c020e4352a3796e5642b\"},\"headline\":\"WordPress WP_Post objects\",\"datePublished\":\"2014-07-08T15:40:34+00:00\",\"dateModified\":\"2021-08-17T02:58:33+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/wordpress-wp-post-objects\/\"},\"wordCount\":408,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\"},\"articleSection\":[\"WordPress Hosting\",\"WordPress Tutorials\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/wordpress-wp-post-objects\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/wordpress-wp-post-objects\/\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/wordpress-wp-post-objects\/\",\"name\":\"WordPress WP_Post objects | InMotion Hosting\",\"isPartOf\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#website\"},\"datePublished\":\"2014-07-08T15:40:34+00:00\",\"dateModified\":\"2021-08-17T02:58:33+00:00\",\"description\":\"In this article, we will show you what information is stored in WP_Post objects and how to access that information.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/wordpress-wp-post-objects\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/wordpress-wp-post-objects\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/wordpress-wp-post-objects\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.inmotionhosting.com\/support\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"WordPress WP_Post objects\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#website\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/\",\"name\":\"InMotion Hosting Support Center\",\"description\":\"Web Hosting Support &amp; Tutorials\",\"publisher\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.inmotionhosting.com\/support\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\",\"name\":\"InMotion Hosting\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg\",\"contentUrl\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg\",\"width\":696,\"height\":696,\"caption\":\"InMotion Hosting\"},\"image\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/inmotionhosting\/\",\"https:\/\/x.com\/InMotionHosting\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/83776252b196c020e4352a3796e5642b\",\"name\":\"Jeff Matson\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/author\/jeffma\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"WordPress WP_Post objects | InMotion Hosting","description":"In this article, we will show you what information is stored in WP_Post objects and how to access that information.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/wordpress-wp-post-objects\/","og_locale":"en_US","og_type":"article","og_title":"WordPress WP_Post objects | InMotion Hosting","og_description":"In this article, we will show you what information is stored in WP_Post objects and how to access that information.","og_url":"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/wordpress-wp-post-objects\/","og_site_name":"InMotion Hosting Support Center","article_publisher":"https:\/\/www.facebook.com\/inmotionhosting\/","article_published_time":"2014-07-08T15:40:34+00:00","article_modified_time":"2021-08-17T02:58:33+00:00","author":"Jeff Matson","twitter_card":"summary_large_image","twitter_creator":"@InMotionHosting","twitter_site":"@InMotionHosting","twitter_misc":{"Written by":"Jeff Matson","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/wordpress-wp-post-objects\/#article","isPartOf":{"@id":"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/wordpress-wp-post-objects\/"},"author":{"name":"Jeff Matson","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/83776252b196c020e4352a3796e5642b"},"headline":"WordPress WP_Post objects","datePublished":"2014-07-08T15:40:34+00:00","dateModified":"2021-08-17T02:58:33+00:00","mainEntityOfPage":{"@id":"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/wordpress-wp-post-objects\/"},"wordCount":408,"commentCount":0,"publisher":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#organization"},"articleSection":["WordPress Hosting","WordPress Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/wordpress-wp-post-objects\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/wordpress-wp-post-objects\/","url":"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/wordpress-wp-post-objects\/","name":"WordPress WP_Post objects | InMotion Hosting","isPartOf":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#website"},"datePublished":"2014-07-08T15:40:34+00:00","dateModified":"2021-08-17T02:58:33+00:00","description":"In this article, we will show you what information is stored in WP_Post objects and how to access that information.","breadcrumb":{"@id":"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/wordpress-wp-post-objects\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/wordpress-wp-post-objects\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/wordpress-wp-post-objects\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.inmotionhosting.com\/support\/"},{"@type":"ListItem","position":2,"name":"WordPress WP_Post objects"}]},{"@type":"WebSite","@id":"https:\/\/www.inmotionhosting.com\/support\/#website","url":"https:\/\/www.inmotionhosting.com\/support\/","name":"InMotion Hosting Support Center","description":"Web Hosting Support &amp; Tutorials","publisher":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.inmotionhosting.com\/support\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.inmotionhosting.com\/support\/#organization","name":"InMotion Hosting","url":"https:\/\/www.inmotionhosting.com\/support\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/","url":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg","contentUrl":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg","width":696,"height":696,"caption":"InMotion Hosting"},"image":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/inmotionhosting\/","https:\/\/x.com\/InMotionHosting"]},{"@type":"Person","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/83776252b196c020e4352a3796e5642b","name":"Jeff Matson","url":"https:\/\/www.inmotionhosting.com\/support\/author\/jeffma\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"primary_category":null,"_links":{"self":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/3346","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/users\/12"}],"replies":[{"embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/comments?post=3346"}],"version-history":[{"count":5,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/3346\/revisions"}],"predecessor-version":[{"id":84222,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/3346\/revisions\/84222"}],"wp:attachment":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/media?parent=3346"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/categories?post=3346"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/tags?post=3346"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}