How to display content from post_parent
As stated by the other answer, you can not pass an ID to get_the_content()
function. You could fetch the post using get_post()
, but there’s also another handy function that you can use to fetch the content:
The get_post_field( $field, $post_id, $context )
function is what you’re looking for:
$content = apply_filters( 'the_content', get_post_field( 'post_content', $post->ID ) );
The the_content
filter also makes sure that some features like shortcodes or auto-paragraphs will work as intended.
Simply replace your second <a>...</a>
with this:
<?php echo apply_filters( 'the_content', get_post_field( 'post_content', $post->post_parent ) ); ?>
Related Posts:
- Double or Single Quotes in WordPress Content Conflicting With HTML
- Post content not showing some content
- How to handle parent and child pages?
- How to correctly add Javascript in functions.php
- Genesis – Customize search form
- Set media upload attachment link to none and hide it in WP v3.5
- How to set custom cookies before output
- Why does this echo values in the wrong order?
- On this day PHP code
- Remove at the beginning of the_excerpt() with str_replace
- How to sort results from a custom database table
- Initiate only latest version of a class
- Check if a user already voted [closed]
- Uncaught TypeError: Cannot read property ‘firstChild’ of null after upgrading to WordPress 5.5
- WordPress if (is_page) translation on certain page
- Uploading video to google drive via frontend [closed]
- Using Font Awesome as post thumbnail
- admin-ajax.php responding with 0
- Batch update a post meta field value of each post in Post Type
- Deregister and Dequeue Stylesheets From a Plugin and Enqueue a Child’s Stylesheet/s
- How to use return in my custom function instead of echo
- Setting All Drafts to ‘exclude-from-catalog’ in WooCommerce
- How to properly insert a link to a template in WordPress?
- Difference between ‘type’ => ‘text’ and WP_Customize_Control
- Locating Global Variables
- $wpdb->flush(); breaks the loop
- get post based on category chosen in drop down – The ajax method
- Is there an equivalent to WP_Error object I can return in the case of a successful REST request?
- Extending the WP_Widget_Text class
- Set the background to a default image if there isn’t a specified “featured image”
- WordPress Access allowed to fewer pages till user logs in
- How to pass aa JS variable to PHP?
- Gutenberg block – Save PHP function’s output as HTML?
- different id for same element visual composer [closed]
- user_profile_update_errors hook not executing
- Adding number to date not working [closed]
- Changing the default object embed sizes?
- How to exclude tags and categories from a function?
- Custom Theme’s “Preview Changes” Doesn’t Work for Previously Published Posts
- WordPress Stripping Colons?
- Custom Field IF/ELSE PHP
- Fatal error: Call to a member function query() on a non-object
- src script only works on home page?
- Run str_replace on title and save the output to a custom field
- Which function crops images in wordpress?
- Should I use WordPress to skin a database website?
- Adding a line of text to php code
- wp_delete_comment takes two tries to delete – then deletes all comments
- WordPress Custom SQL Table with UserID Filter for results
- How to end a while loop when used in a fetch assoc function [closed]
- Why my loop isn’t working? [closed]
- Menu Custom Data Attributes
- Pass return-path additional parameter in wp_mail
- How to get image from url from the database?
- WordPress meta_query >= &
- How to override a plugins script
- Front end file upload returning wrong attachment url
- Comparing Dates from custom field
- Taxonomy term description with style, only if the description exists?
- Ajax URLs without #!, how to prevent falling into single.php on load or reload?
- PHP displaying wrong custom taxonomy images
- Page load timer?
- How to sort posts by active category in WordPress?
- wordprees multi-site in user panel add filter
- How do I know if the user is a customer?
- WordPress custom php script to match standard page layout
- copy fields value to another field
- Get parent category name when only child category is applied to a product
- Updated Php version from 5.4 to 7.2 and getting “PHP installation missing the MySQL extension needed by WordPress”
- Modifying child theme’s header
- Before & After Content – After Content directly below Before Content when using require_once
- Get Child of Child Pages in custom Menu
- Latest posts feed with a specific post always first
- Top Authors list by highest post views with Ajax pagination
- WordPress Post undefined error with Post Date (New to Wordpres Dev)
- From php web to wordpress conversion, href changes only in URL
- How can i put php code on the wordpress page?
- What’s the correct offset value for order ASC?
- Setting at job with shortcode not working
- How to solve 404 permalink errors on nginx server
- Ajax Load more CPT via shortcode
- Order by in foreach
- Sort by multiple options in custom field
- Query seems to be duplicated
- two sites, same code, different presentation
- WPMU schedule doesn’t execute actions
- ISOTOPE – Missing/Invalid Arguement Get Terms
- doubled content
- Add Condition if WPBakery Page Builder Used on Page or Not
- Data inserted in database, but ajax calls error function
- how to import contacts from php to wordpress
- How to add active class dynamically
- I’m not able to get access $wpdb in my php file in wordpress
- Add attribute to featured image with filter (wp_get_attachment_image_attributes)
- Should I use include(_once) or require(_once) for loading php-file with customizer settings?
- How to create a WordPress PAGE in another folder?
- How do I edit the text in this function.php file?
- How to create custom user role without plugin?
- WordPress 6.1.1 shows deprecated errors with PHP 8.1 & 8.2
- Include a static block inside of a dynamic block