Get post content from outside the loop
You can use get_page()
to return the $post
object of a static page:
$page_id = 302;
$page_object = get_page( $page_id );
echo $page_object->post_content;
Edit
Similarly, you can use get_post()
to return the $post
object of a post:
$post_id = 302;
$post_object = get_post( $post_id );
echo $post_object->post_content;
Related Posts:
- WordPress: Loop Help
- Query posts only with actual text content (not including shortcode or images)
- Custom content before post content
- How to display Yoast SEO meta description in archive template for each post instead of the_excerpt()? [closed]
- Display featured products through custom loop in woocommerce on template page
- Child Pages Loop
- Loop.php vs looping inside template file
- Insert/sticky specific post into Loop at specific location
- Style every four posts differently [duplicate]
- Return vs Echo Shortcode
- Show newly added posts since last user login time /date
- Use the_content outside the loop
- have_posts() return false but count says “3”
- next_posts_link not working in custom loop
- How to sort posts in archive loop
- wordpress loop and template files
- How to iterate through database until it find a match
- Show top level comments ordered by number of replies
- Creating nested forum loops in bbPress [closed]
- Adding active/current class to get_terms list
- Redirect Loop to Page, Can’t Find Origin, Can’t Remove [closed]
- wordpress change the loop order by dynamic value
- Post Format single-loop.php using get_template_part
- Display posts from multiple user roles
- Display content of page template (get_page)
- Prevent Headers from being sent
- How do I get row padding in a post feed?
- Display the_content on click jquery
- How can I create a legend (Key) like the one in the footer on WordPress StackExchange
- It is possible to encounter horrible bugs if I place a main loop that uses `query_posts` right above the main bbPress loop?
- Missing image in gallery shortcode in custom feed
- Including post thumbnail url in loop’s post object to reduce number of queries
- How to show “teaser” posts on blog / archive pages, otherwise full posts
- Make blog page show 10 on first page, 9 on every other page
- Duplicate posts in paginated results
- Alter query using pre_get_posts() if meta_key is present
- Next Posts Prev Posts for Standard post format only
- Two loops on different pages do the same thing, but only one page works
- Posts active and expired in different loops
- Genesis multiple category custom loop 404s after first page
- Shortcode in posts called by ajax is not working
- Using Javascript for Looped Content
- Making a query to the DB using same parameters of loop
- Variable not being passed into WordPress loop
- Exclude duplicated $sticky post from combined loop content
- Getting a custom field in the middle of a loop
- Pagination on Single Post
- Display Posts Only with Specific Tag
- How to get my loop to paginate?
- Get author Meta for particular user inside the loop
- WP Loop. If featured image is a panorama (3:1 ratio) execute some code
- Trying to get property of non-object in shortocde
- Foreach displays from last to first
- value of metadata is null wrong use of if statement
- Count post views in loop
- How to Loop with the final result formatted differently?
- Tags on page (not post) returns nothing – why? Improved clarified question!
- Separate First Post Loop
- add offset to archive page
- Category ID returns as ‘0’?
- make get_post work in the loop
- How to display 3 post per slide
- Show terms in archive page
- For Each +1 WordPress Loop
- Loops for cat links not looping for wordpress site
- Skip 5 latest post while paging?
- WordPress: query pages except remove one page
- get_post_meta printing empty fields, but it shouldn’t be
- Sort posts according to a numeric value entered with ACF
- Is it possible to set archive.php instead of index.php to display blog?
- How to read taxonomy in loop?
- wp_get_attachment_url not fetching URL?
- get the value for ALT is we check to see if an actual ALT value is set, if not we use the caption and if no caption is set we use the title
- how to add 4 post in one carousel slide
- How to get all multi-select user meta values and add them to an array?
- How to resolve a reload loop issue in the frontend when logged in to WordPress multi-site backend admin area
- Exclude Posts Using Meta Query and User Meta
- Is “the loop” a template tag?
- Can I temporarily disable global $post?
- Shortcode for pulling specific Post Title outside loop when ID is passed in
- Show a list of user posts in the user admin page
- WordPress with woocommerce custom query
- Infinite Loop after Genesis Theme Upgrade
- Page gets displayed in post field
- Active class for my flexslider in WordPress
- WordPress loop only displays 5 articles max?
- get_template_part() to render single page Theme
- Can’t see custom field after the Loop [closed]
- Showing related posts (custom post type) outside of the loop
- Same Loop on Multiple Pages
- Paged homepage – requirements?
- Least Number of Loops to Create Custom Homepage?
- The Loop for my theme with static front page is not working
- WordPress loop: Display if posts exist
- strange parse error when including a loop template within another template
- Previous Posts Link and Next Posts Link Show All The Same Articles?
- Showing ads after posts in home page
- How to handle parent and child pages?
- Undefined variable: woocommerce_loop [closed]
- Prevent duplicating specific column from database table