Getting post revision and printing them on the post content site
I trying to print older post revisions on the content.php site (theme: twentytwenty), and this, with staticly set value works..
$query = $wpdb-prepare(SELECT * FROM {$wpdb-prefix}posts WHERE post_type = 'revision' AND post_parent = '6');
But if I wanted this dynamically for each post it prints me only ID of post and nothing more.. That magic piece of content.php:
?php
$post_id = the_ID();
global $wpdb;
//$result = $wpdb-get_results(SELECT * FROM wp_posts WHERE post_type = 'revision' AND post_parent = '. $post_id.';);
$query = $wpdb-prepare(SELECT * FROM {$wpdb-prefix}posts WHERE post_type = 'revision' AND post_parent = '%d', $post_id);
$results = $wpdb-get_results($query);
foreach($results as $row) {
echo 'h6 class=max-percentage style=text-align:center;Verze článku z: '.$row-post_date.'br/h6';
echo $row-post_content.'br';
}
?
I also tried lot of ways what I search on google but no one works for me.. Any tips?