<?php
function loadmore_post_ajax($attributes)
{
	// print_r($attributes);
    $ppp = (isset($_POST["ppp"])) ? $_POST["ppp"] : 3;
	header("Content-Type: text/html");
	$selectedStyle = isset($_POST['selectedStyle']) ? sanitize_text_field($_POST['selectedStyle']) : '';
	$displayFeaturedImage = isset($_POST['displayFeaturedImage']) ? sanitize_text_field($_POST['displayFeaturedImage']) :'true' ;
	$displayDescription = isset($attributes['displayDescription']) ? sanitize_text_field($attributes['displayDescription']) : 'true';

	// Include the file where artcloud_posts_render function is defined
    include_once '/artcloud-posts-render.php';

    // Set up attributes for artcloud_posts_render based on your requirements
    $ajaxAttributes = array(
        'postType' => 'post',
        'numberOfItems' => $ppp,
        'selectedStyle' => $selectedStyle,
		'displayFeaturedImage' => $displayFeaturedImage,
		'displayDescription' => $displayDescription,
    );

    // Call artcloud_posts_render with the AJAX attributes
    $output = artcloud_posts_render($ajaxAttributes);

    // Return the rendered HTML
    die($output);
}

add_action('wp_ajax_nopriv_loadmore_post_ajax', 'loadmore_post_ajax');
add_action('wp_ajax_loadmore_post_ajax', 'loadmore_post_ajax');

//

