/*
Theme Name: Hello Elementor Child
Theme URI: https://yourwebsite.com/ (optional)
Description: Child theme for Hello Elementor to customize single posts.
Author: Your Name
Author URI: https://yourwebsite.com/ (optional)
Template: hello-elementor
Version: 1.0
*/

/* Import the parent theme's styles */
@import url("../hello-elementor/style.css");

/* Add any custom CSS here if needed */

// Shortcode to display another post's content
function display_post_content_shortcode($atts) {
    $atts = shortcode_atts(array(
        'id'    => '',      // Post or Page ID
        'slug'  => '',      // Or use slug instead of ID
        'title' => 'no'     // Show title? yes/no
    ), $atts);

    if (empty($atts['id']) && empty($atts['slug'])) {
        return '<!-- Post ID or Slug required -->';
    }

    // Get post by ID or slug
    if (!empty($atts['id'])) {
        $post = get_post($atts['id']);
    } else {
        $post = get_page_by_path($atts['slug'], OBJECT, ['post', 'page']);
    }

    if (!$post || $post->post_status !== 'publish') {
        return '<!-- Post not found or not published -->';
    }

    $output = '';

    // Optional title
    if ($atts['title'] === 'yes') {
        $output .= '<h2>' . esc_html($post->post_title) . '</h2>';
    }

    // Full content with shortcodes, images, etc. processed
    $content = apply_filters('the_content', $post->post_content);
    $output .= $content;

    return $output;
}
add_shortcode('post_content', 'display_post_content_shortcode');