The $post
object is not available outside the Loop, unless you globalize it before referencing it:
global $post;
$variable = $post->post_title;
Related Posts:
- Retrieve each widget separately from a sidebar
- Adding ‘current_post_item’ class to current post in the loop
- is_active-sidebar loop
- WordPress shortcode in content, output in sidebar?
- Exclude current post ID from loop in sidepbar.php
- Split Content and Gallery
- Do I need to use The Loop on pages?
- How to return loop contents
- How to get the first image gallery of a product in woocommerce in a loop
- the_content and wp_link_pages
- the_title(); works in a page template, outside the loop. Why?
- Add 20yrs to post date, and then query
- When and Why is is_singular(‘my_cpt’) true while in_the_loop() is false?
- as a shortcode within the loop?
- Getting page ID inside loop
- Page template not displaying
- How to show just private posts in loop
- How to paginate this custom loop? [duplicate]
- Select data from database and list it in Loop (WordPress)
- How to get_template_part using AJAX?
- How can I modify the loop from a plugin without wiping out other filters?
- wp alchemy multiple image uploader output images to template
- Running a loop with a custom query string on a custom page template
- Complex query and posts pagination
- Displaying terms based on loop posts?
- Loop in Related Posts WordPress
- Conditional query that displays on Woo product attribute pages
- Custom post type appearing within the previous one on archive.php
- How do I go about looping through a advanced custom field on a particular page inside of another page
- How to inject posts from certain category on home page
- The Loop – mixed ASC and DESC order
- Filter the_posts doesn’t work on search page
- Custom Loop Using Shortcode in Custom Page Template
- Listing subpages title and content and styling the first iteration differently
- Showing sticky posts with get_posts()
- single.php – how to mark current page in the loop
- Cannot retieve the_content() and the_author() – both returning empty strings
- How to order by multiple fields using standard query_posts?
- Get 1 more post in loop
- Pagination not working in category listing [duplicate]
- How do I get my loop.php to properly paginate?
- Category links including all posts
- Custom loop ordering not working
- First archive page with a few posts
- Hiding a row in the loop if empty
- How to display first post
- Pagination on custom post type on front-page.php
- get_template_part() Not Working in Loop
- get_delete_post_link() inside Loop stubbornly returns nothing
- CPT while loop not working
- Problem with Front-Page.php loading recent posts
- Comments_template doesn’t work
- Get markup for post without loading into the template
- How can this multiple loop have pagination as described?
- Default featured image set as background image [closed]
- Breaking up the results of a loop
- Where to add offset?
- How to synchronize The Loop with the max post per page?
- How to add a byline to all the pages?
- Displaying member join date on page
- Ascending order has strange effects on wordpress loop
- Is file_exists() compatible with timthumb.php? [closed]
- get post images to link to external sources
- Set depth of pages to fetch
- Trying to get all links in my posts
- Creating a User-Adjustable chart in WordPress
- Archive: Lists itself
- Reorder posts in a loop: have the posts by one particular author below the others
- Slug is changing when I use WP_Query in a metabox of a post
- How to execute a user loop with shortcode
- how to get author comment inside the loop?
- How to create loop in custom page, and get id from url into this loop?
- How to fix pagination for custom loops?
- Check to see if a field is within an array in twig
- Custom loop not working in singular.php, working in other pages
- Loop Posts Outside of WordPress Installation
- Strange problem with wp_get_attachment_image_src database (db) query count
- How to include posts from one category, into a separate category of posts?
- how do i make this loop work
- Making a specific page wordpress compatable that is not index
- Display single post inside accordion based on form submission results
- One page loop issue with posts
- Humanmade | Custom meta box class: How to display a repeatable meta box group?
- The Loop isn’t working
- Changing the loop w/o killing category links
- Custom loop page with post navigation
- Pages with a loop (index, archive) are loading the first image as post_thumbnail
- the loop – how to control whether wp or plug-in runs it
- stuck with template hierarchy
- An action that runs after each post in the loop on index/archive page?
- Modify my code – which takes the first sentence of the post and use it as a h2 tag – to work outside the loop
- How to show only specific tag in wordpress loop
- Getting post id in for loop
- Different style for first two (sticky) posts
- WooCommerce – Checkout suddenly stops working [closed]
- Want to images load first then title in WordPress loop
- How to add a continuous number to HTML tag attribute value inside The Loop [closed]
- WordPress Not Sorting By Custom Field
- Landing page with login
- How can I create an entirely new, separate display of posts?