<?php
	get_header();
?>
<?php do_action('ftm_before_content_hook'); ?>
<div class="ftm_404_content_wrapper site_content_wrapper">	   
    
    <?php 

    global $wpdb;
    $page_title = '404'; // Replace with the title of the page you want to retrieve.

    // Perform a direct MySQL query
    $page = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->posts WHERE post_title = %s AND post_type = 'page' AND post_status = 'private'", $page_title), OBJECT);

    
    $content = '';

    if ($page) {
        // Page found, and you can access its properties
        $page_id = $page->ID;
        $post_content = $page->post_content;

        $blocks = parse_blocks( $post_content );                

        foreach($blocks as $block){
            $content .= render_block( $block );
        }
    }

     if($content != ''){
        echo $content;
     }
     else //No page with the title 404 was found so we use the fixed default content
     {
    ?>
        <div class="content_container">
            <div class="left-column">
                <div class="child-div"><h1>404</h1></div>
                <div class="child-div"><b>Oops, we can’t find the page you’re looking for... </b></div>
            </div>
            <div class="right-column">
                <div class="child-div">
                    <img src="<?php echo get_stylesheet_directory_uri(); ?>/assets/images/page-not-found-min.png" />
                </div>
            </div>
        </div>
    <?php 
    } 
    ?>
</div><!-- .content-area -->

<?php get_footer(); ?>
