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
- Show one item per category of a custom post type
- Two near-identical custom field types – one works, the other doesn’t . What can cause this?
- Meta Key Value in current-user-only loop
- How to display all posts from standard posts to custom post types in a loop with pagination?
- How to customize a permalink (URL) structure?
- Calculate all custom field values in the post loop
- CPT + CMB2: data not displaying for only first post in loop
- Get next and previous 3 posts in a term in single post page
- Custom Post Type with Templates using Meta Boxes?
- Can I list a custom post type within another custom post type in the admin area?
- Change custom post type slug from plugin options
- Loop custom taxonomy to get lists of cutom post types?
- How do i calculate the total of values of custom fields in custom post types?
- Multiple Loops On Custom Post Type Template?
- Custom loop with multiple taxonomy queries
- I would like to have different styles for my posts based on the content of each post
- Checking if Post Title is Unique as Loop Criteria
- Custom post type not displaying content from single-{custom post type} page
- Can’t edit custom post type
- Custom post type multiple loop by taxonomy term
- List custom taxonomy specific to one custom post type
- Show a Category X’s custom post type on Category X archive page?
- Paging doesn’t work?
- Sort by alphabetical order archive.php page
- Set URL link to featured image of custom post type
- What is the recommended / best way to do this: Event calendar post/type in a block-based theme?
- Change CPT archive title
- Custom Tag Description unable to display just below and outside of the Loop
- AJAX load more for different custom post type loops
- PHP variable not regenerating when publishing multiple posts at the same time
- On update or create post redirect to current post position in list
- Display all taxonomy terms, add class if term applies to current post
- I need to add endpoint for wordpress categories
- Return the latest post from a custom Taxonomy and Post Type
- Displaying CPT and custom taxonomy side by side in Bootstrap 4 component
- How to target a specific custom post type post and its all children and grandchildren?
- Featured image overlay when changing post status
- get_post_meta not working on publishing
- Group CPT posts by custom taxonomy
- Redirect 404 page with ID in slug to associated page with same ID in slug
- WordPress wrapped added a span tag to every single p tag
- ACF field key/value to show on taxonomy list
- Re-registering a custom post type not working (not showing up)
- Display featured image from one CPT within another CPT query
- Query taxonomy of taxonomy of custom post type
- Store CPT ‘Reviews’ average ratings to a WordPress DB table or to a DB custom table?
- How to make custom posts types display when published for the future
- A to Z List of Custom Post Type in three columns
- Custom post type, organized by categories
- What’s the WP way to load remaining custom posts?
- How to rewrite url for any specific taxonomy?
- create a new page from a custom post type similar to an authors page
- CPT archive admin menu label
- Anon function and add_meta_box
- WP Query with categories only shows one post and ignores the category
- What to and how to proceed with CPT to make DB small and efficient?
- Post ID randomly printing on page
- A custom post within a custom post
- Display Custom Taxonomy Alphabetically
- Full Custom Post Type List Organised by two Taxonomies
- Hide a widget inside a div on specific type of post
- Displaying Custom Posts on a Page
- Problem: wp_query outputs all images on site
- Changing default ‘posts’ parameters with register_post_type_args
- Get custom post type’s fields in a while loop as variables
- Custom Post Type within the Loop on Homepage (Page Template)
- The loop seems stuck to a single (now deleted) post
- Homepage’s content is dependent on the custom field values (set automatically), how do I get homepage to update without manually updating page?
- Cannot save CPT meta box
- Posts per row on archive page (custom post type)
- How do I know the ‘meta_key’ for ordering my custom post type
- Allow users to create posts without logging in?
- How to change permalink to include custom post type
- Custom Theme With Custom Loops
- Configuring a meta query with multiple post types that have the same relationship on a single page
- Custom Post Types strange pagination problem
- Add term to custom post type on draft
- How to assign classes to all elements?
- next_/previous_post_link() `in_same_category` appears to fail when true
- Custom post type conditional in loop
- Listing all term items alphabetically / sorting loop
- Want to be able to sign up subscribers as authors
- Display related custom taxonomy posts in sidebar
- Load scripts based on post type
- pagination not working for category.php (custom post types in categories)
- Only show posts with date of today or in the future (i.e don’t show past posts)?
- How do I control the output of a custom post type in the loop?
- Different Category system needed for the Custom Post Type