The answer can be found in the documentation for get_the_title
:
$post
(int|WP_Post) (Optional) Post ID or WP_Post object. Default is global $post.
If you don’t supply a post object or post ID, it defaults to using the global $post
variable.
When you call the_post()
within the loop, this populates the global $post
variable with the data from the current post within that loop.
EDIT:
get_the_title
gets the current post object:
$post = get_post( $post );
get_post
then accesses the global $post
if nothing was passed to it:
$post = $GLOBALS['post'];
Related Posts:
- Best way to style first post differently?
- Custom post type loops with different page templates
- How do you output custom code between posts in the loop?
- How would I create a shortcode to display a custom post within a page or regular post?
- Best way to style first post differently?
- Shortcode not working with post counter
- Loop increase number
- Get post format
- posts within custom post type all share the same content in the front-end
- Get Posts List of Current Selected Custom Taxonomy in Shortcode
- Pagination not working in custom post type. Help
- subtracting the current post form then whole loop, which is generating all CPT titles
- Pagination not working with custom loop
- Display all posts starting with given letter?
- wp_pagenavi() with custom wp_query()?
- how do I group content in magazine-style ‘issues’?
- How do I add a custom post type to the Featured Content in twenty fourteen theme?
- Should unaltered default loop/query return a list of custom posts belonging to a custom taxonomy?
- 404 error PageNavi custom type taxonomy | wordpress
- Multiple Content Block
- Query for posts in 2 taxonomies
- IF statement in a do_shortcode
- Allow Users Access to Custom Post Type Only
- How to get Custom Post ID by adding filter to child theme’s function
- How to dynamically build a multiple taxonomy query loop within a post type’s single loop?
- When ‘is_post_type_archive()’ return true?
- How to check if “is single” page
- How to add the post ID (or any other post data) to a Contact Form 7 mail?
- How To Enable Block Editor (Gutenberg) for Existing Post Type via functions.php
- Using pre_get_posts to filter one loop in a multiloop archive
- Custom Post Type Loop within Shortcode
- Create a post in custom post type using field in registration form after users submit form
- right_now_content_table_end function not working?
- Display CPT posts based on specific taxonomy
- Meta Key Value in current-user-only loop
- CPT + CMB2: data not displaying for only first post in loop
- Loop custom taxonomy to get lists of cutom post types?
- Show a Category X’s custom post type on Category X archive page?
- Sort by alphabetical order archive.php page
- How to target a specific custom post type post and its all children and grandchildren?
- ACF field key/value to show on taxonomy list
- Displaying Custom Posts on a Page
- Homepage’s content is dependent on the custom field values (set automatically), how do I get homepage to update without manually updating page?
- Configuring a meta query with multiple post types that have the same relationship on a single page
- Add term to custom post type on draft
- Custom Post Type Category Link
- Custom Post type category pages template and loop
- Three Most Recent Posts, One Per Term
- Template not working for the custom Post type
- Custom Post Loop pulling all custom posts, not just one
- Wrapping x posts in html without leaving empty html
- ACF in wordpress
- Change Slug of a Custom Post Type
- Move Genesis Single Page/Single Post Title
- Post loop count is not in order
- How to inherit field value from parent post into in child / sub post
- hide specific div on single.php [closed]
- Looping Through Categories of a CPT
- How do you output an unknown number of images in a custom post type with desired markup?
- Custom post type’s posts are not showing anywere but in xml sitemap
- Show current user posts in custom post type query
- Rewrite permalink for multiple post types (CPT) with taxonomy term
- Assign a template to a custom post type when displayed by the main loop on the home page
- Custom post type in Custom widget – $listItem
- The loop does not show users
- Displaying information from custom field on custom post type
- Display only a single CPT
- Control Loop Within Loop
- How do I enforce a specific custom post type on the loop
- How do I list a custom field and custom taxonomies for each result in a loop?
- Show the categories the current post has
- Conflict in function to allow single post template based on category
- set object terms after some some time of published post – functions.php
- Is there a way to use ‘publicly_queryable’ => false only on specific taxonomy term?
- Urgent – WordPress keeps creating posts
- ACF field check value of field on all other articles
- Problem with multi checkboxes value in metabox?
- Loop (for search results) returning right posts, but wrong post type
- Send mail to author when custom post type is saved
- Recovering data about custom post and taxonomy types
- WordPress trying to query two custom types to get child from the parent
- Display title of all custom posts from same taxonomy term on a custom post template
- wordpress does not see the correct custom taxonomy hierarchy
- is using “require_once” in wordpress theme affect the speed ???
- get_permalink() of page the enclosing page not posts
- How to sort custom post’s category by id from the theme’s function.php?
- WordPress query in which condition uses custom field
- Error in WP Query. If variable is empty it is displaying previous post value
- WP_Query function for custom post type
- Pagination in custom post type page template
- Modify shortcode to work with custom taxonomies and slugs
- Calling the first & last post by category in custom post type
- Query custom post type and showing its content
- Custom Post Type Order Index Loop
- WordPress nested loop not working
- Order by custom field attribute
- Display Custom Taxonomy of custom post type
- next_posts_link returns same content of 1st page
- Code in custom widget queries all posts, when it should only query the current post
- How to loop through a custom post type using a shortcode and output each element in the loop using shortcodes